-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal viewer's wrong position on view find file's result #3530
Comments
It was me rewriting the core of the viewer for 4.8.14, in ticket #3250. This particular question, the behavior near the end of the file was mostly discussed in ticket #3256.
Both tickets had some quite heated discussions on what the behavior should be. After a while these discussions stalled without an agreement. Later on they applied my work with my design.
See those threads (especially the opening description of 3256) for why I chose this behavior.
I'd be happy to implement the other behavior as an option if there's popular demand for that and if mainstream developers express that they'd accept having such a new config option. But first I'd also like to hear your opinion on why you find the current behavior inconvenient. The current behavior is how pretty much every modern graphical application works nowadays. |
|
It's not about whether new scrolling behavior if better than the old one. It's about the fact that with old behavior, when you press F3 inside search dialog you're used to look at the very top of the screen to see the matched line. Now you have to look for it through all the screen, or press F7+Return once inside the viewer so that the match is highlighted. I think an improvement in the form of highlighting the match right away would be fine (at least for me, can't talk for OP). |
I don't understand what you mean... the search result is highlighted, isn't it? How does F7+Return help? What are the exact keys you press to search so that the result is not highlighted? Seems you may have found another bug. |
The steps are:
Supposing the match is at the end of file,
I'm using 4.8.14 and right now the result is not highlighted after step 3. |
I see, you're right! I completely missed this use case.
Could you please file a separate bugreport for this? |
My bad, I didn't realize the original report was also about this, rather than just simply searching in mcview. Sorry! I guess we could then keep this ticket for highlighting the search result when going there from Find File.
eshkrig, would this also be good for you? The search result wouldn't necessarily be on the top, but would be highlighted. |
Either method is suitable: matched line is at the top of the screen {and|or} it is highlighted. |
Thanks for your input. I'll do the highlighting. It's more complicated than I hoped it would be, but already made some progress. I hope it'll be done in a couple of days. |
Thank you very match! |
Proof of concept fix |
First version attached. It seems to work, but still requires heavy cleanup.
Can you guys recompile and try mc with this patch, and send feedback? |
When applied to 4.8.14, I get this crash:
When applied to master, I get a bit different crash:
|
Oops...
In src/filemanager/find.c, around line 873 there's a g_malloc (sizeof location); could you please change that to g_malloc (sizeof *location); [just add one star character] and try again?
This is a stupid mistake and I wonder why it didn't crash/misbehave for me :) |
That works well. The only thing missing is horizontal positioning when lines are longer than screen width and match is outside the screen (with line wrapping disabled). But since searching within the viewer with F7 doesn't scroll horizontally to the match either, I think this is another issue, don't remember whether pre 4.8.14 mc did that. |
Cool, I'll go ahead and clean up this patch.
I think horizontal scrolling to the match never worked, IIRC there's a ticket for that. |
Fix |
Please test and review the attached patch thoroughly.
I expanded the "invisible" data stored for each list entry. So far it only contained the directory in which the file resides - a perfect match for list entries' userdata field. Now they encapsulate the directory name, plus start and end offset for the matches. For this reason a complete struct needs to be allocated and its pointer passed there. I also needed to add infrastructure to optionally automatically free the userdata when the list entry is removed.
mcview_viewer() and friends also had to be extended by two new arguments: the start and end of the area to be highlighted.
The logic in find_add_match which keeps track of the offset within the file is very complicated. I hope it's bugfree (I've tested even with embedded NUL bytes) but a second eye would be great. |
So, just to be clear about it, after this patch, it will highlight the match, but the match is not going to be at the top of the screen as before? I'm also kind of missing this, it was hugely convenient. In fact, I use 4.8.13 at home still... |
Not if the match is near the end of the file.
The new viewer - discussed in the aforementioned links - makes it a hard requirement never to waste screen real estate at the bottom when it could be used to display more data from the file. A file that's taller than the viewport can't be scrolled beyond the position where the end of the file appears at the bottom of the viewer. No exceptions.
Just as e.g. your browser also won't scroll the bottom of the content to the top of your screen, leaving tons of whitespace below that does not belong to the page. |
Replying to egmont:
Branch: 3530_view_highlight_search_result
I've split the patch to three commits:
|
Awesome, thanks! I guess I should have done it :)
I was primarly wondering whether you liked the overall approach... but I'm glad that you like the patch as well.
One thing to note: in the spirit of #39 this patch introduces another bug: in Parsed mode a totally irrelevant segment of the file could be highlighted when you open it. Preventing this bug would require a totally different, more complicated approach (maybe opening the file at the given line, and then performing the search again). I honestly don't care too much and really don't want to start over this patch with a different approach, I think we could live with this minor bug and add a note to #39 to address this one day. |
|
Merged to master: [5ef1b4b5f972575ccb306afbe001354fad7cce85].
|
|
Hi Andrew,
https://www.midnight-commander.org/wiki/NEWS-4.8.14?action=diff&version=41
this was supposed to go into NEWS-4.8.15, right?
Thanks! |
Replying to zaytsev-work:
Yes. Fixed. |
Important
This issue was migrated from Trac:
eshkrig
(eshkrig@….com)egmont@….com
(@egmontkob)Hi!
Sorry for my English.
Since version 4.8.14 there is a problem: "Find File" -> "Content" -> "View - F3" - line is not on the top in the internal viewer if found line is near EOF. Interested line maybe anywhere on the screen - this is very inconvenient. Old good behaviour is broken.
Please, fix it.
Thank you!
Note
Original attachments:
egmont
(@egmontkob) onOct 2, 2015 at 23:21 UTC
egmont
(@egmontkob) onOct 3, 2015 at 18:52 UTC
The text was updated successfully, but these errors were encountered: