-
Notifications
You must be signed in to change notification settings - Fork 195
Extra lines of context above/below search results #190
Comments
👍 |
4 similar comments
👍 |
👍 |
👍 |
👍 |
Would be awesome to have this enhancement in. I think most of us can give it a try send a PR, anyway. It should be updated in at least the following locations: in the |
This is really a missing item. 👍 |
+1 |
👍 Really need this. |
+1 |
1 similar comment
+1 |
+1 PARFAVAR |
+1 |
👍 (as this is the only real argument preventing global atom adoption in my company... instead of ST) |
👍 |
If anyone has a fork of Find and Replace that adds this functionality, please comment. |
👍 |
5 similar comments
👍 |
👍 |
+1 |
👍 |
+1 |
+1 This would be incredibly useful - right now, I drop to a shell and use grep -A3 -B3. |
+1 |
Hello, This will nearly be 2 years since this issue has been opened, and it is still the most bothering everyday problem with atom in my opinion. Could you please at least aknowledge this issue, even the answer is "we think it's useless and we won't do it" ? Thank you, |
That's definitively THE missing feature of atom... |
@dmo-odoo this has been tagged as an "enhancement" which basically means don't hold your breath for this to get "fixed". Unless it's a bug there can't be an expectation for it to be fixed. Below is complete speculation on my part: There could be performance considerations which is why this feature is not built in. I mean, it's clear that the folks at Atom have noticed this feature in Sublime Text. If it's not already there, there's a reason why. Even better: it's totally open source! you can see the parts of the code that enable this feature. Add the enhancement yourself and send in a PR. That should kick start the process again. If you're not sure how, you'll have to be patient for someone else to do it. That's unfortunately how the game works. |
https://github.com/atom/find-and-replace/blob/master/lib%2Fproject%2Fmatch-view.coffee#L11-L12 This is where you can change the display of the lines. I'll give it a shot but I'm not familiar with the build system of atom packages and I found no documentation so far. Found it! https://discuss.atom.io/t/load-developing-package/2554 This is how the ResultsModel looks like. The problem is, that the match (lineText) only includes the line of the matched text. |
I got the extra lines, now I only need to properly format it. I could find no documentation about the View elements :/ lines = atom.project.findBufferForPath(filePath)?.lines
prefixLines = lines.slice(range.start.row - 2, range.start.row)
suffixLines = lines.slice(range.end.row, range.end.row + 2)
# if range.start.row <= 2
# prefixLines = lines.slice(0, range.start.row)
# if range.end.row >= lines.length - 2
# suffixLines = lines.slice(range.end.row, lines.length)
@li class: 'search-result list-item', =>
@span range.start.row + 1, class: 'line-number text-subtle'
@span => @raw prefixLines.join('<br>')
@span class: 'preview', outlet: 'preview', =>
@span prefix
@span match.matchText, class: 'match highlight-info', outlet: 'matchText'
@span match.matchText, class: 'replacement highlight-success', outlet: 'replacementText'
@span suffix
@span => @raw suffixLines.join('<br>')
I actually did it! it's not nice, but we will refactor it in the PR then. |
@MartinMuzatko You make me very happy |
@MartinMuzatko You are awesome! |
😊 thanks guys, I do my best to fix this. |
👍 |
👍 it's really missing feature |
👍 |
That looks great! Hope it's in the product soon. |
@isuraed it is not that easy, there are a lot of things to take care of, but it is possible. |
👍 💝 |
👍 |
+1 PLEASSEEEEEEEE 👍 |
I think I'll try it again during my winter vacation. As said: there are a few more aspects to it. but maybe finally I can finish it up. |
@MartinMuzatko: oh man that would be sooooo nice!!!! 👍 I am really missing this after switching over from sublime. Sublime does such a great job at this. It is just so much easier to find the right places you are searching for. |
Just thinking: a good reference on how to layout the results is the way that github displays search restults, p.e. here https://github.com/meteor/todos/search?utf8=%E2%9C%93&q=.call |
Not sure if it's truly related to this issue, but I hate seeing the same line printed twice (or more) when the word I'm searching for just happens to appear twice (or more) in the same line. Example: Just something to keep in mind for whoever ends up working on this (and a pre-emptive Thanks to @MartinMuzatko if you do end up working on this over the holidays) |
@spencerhakim That was already discussed and I believe the consensus was that code-wise, it would be the most logical to tackle it separately from this one. |
@50Wliu Ah, that's what I get for not reading through all the comments. Thanks for getting me up to date. |
No problem. I think the discussion actually happened on the PR anyway. |
I thought about the way PR #702 is implementing the feature and am a bit worried that the overhead due to opening a buffer for every result might be high in cases of large scale (many search result / search results in large files). Therefore I described an alternative approach In #827. Any feedback on this would be highly welcome - especially any experience on the overhead of creating buffers for each result would be valuable to make an informed decision. |
👍 👍 👍 |
This has been implemented in #847 which has been merged for the upcoming beta of Atom 1.17. So I think this can be closed. |
ST includes two lines above and below search results for context, which I regularly found useful and would love to see included in Atom.
Ideally the line count would be a setting instead of hardcoded:
🍻
The text was updated successfully, but these errors were encountered: