stefankueng / BowPad

A simple and fast text editor with a ribbon UI
http://tools.stefankueng.com/BowPad.html
GNU General Public License v3.0
645 stars 84 forks source link

Match highlight slows down search operation in large documents #145

Closed wmjordan closed 3 years ago

wmjordan commented 3 years ago

The search operation in large documents is slow. I guess it is because BowPad has to search the whole document and highlight each matches in the scroll bar.

Is it appropriate to add an option into the Find/Replace dialog to highlight matches, so we can temporarily disable this when working with large log files?

stefankueng commented 3 years ago

the search/mark highlights don't just show up when searching via the find dialog. So how about adding a button into the vertical scrollbar at the top which toggles the highlights on/off? And then store that state for each document, with the default being 'on' for all files smaller than say 200MB?

wmjordan commented 3 years ago

host about adding a button into the vertical scrollbar at the top which toggles the highlights on/off?

The highlight goes on after the Find button in the Find/Replace dialog is clicked, and goes off when the Find/Replace dialog is closed. Its appearance has quite closed relationship with operations in the dialog. So, it may be more intuitive for users to switch a checkbox in the dialog rather than a toggle button on top of the scrollbar.

store that state for each document, with the default being 'on' for all files smaller than say 200MB?

This consideration sounds good since it is per document. However, a user may have his own preference majorly determined by the performance of his machine, not each document. Thus a global option may be sufficient.

We might use a text box within the Find dialog rather than for that setting instead of a checkbox or a toggle button like: Highlight matches if document is less than [ 200 ] MB

stefankueng commented 3 years ago

You can also search by selecting text, then hit Ctrl+F3, that way you won't see the find dialog at all

wmjordan commented 3 years ago

Oh, that's really a good problem. So, the toggle button on top of the scrollbar may be the way to go.

wmjordan commented 3 years ago

Could this be the interaction between BowPad and the user?

By default, the toggle button is pressed (highlight on). If the highlight procedure has traveled quite a long span of a document, the procedure stops working and flashes the toggle button (pops up the toggle button) to remind the user to hit it again to continue highlighting.

stefankueng commented 3 years ago

thinking about this a little more: maybe you're right and the best way is to handle this in the find dialog...

I implemented a button in the scrollbar, but at the bottom, not at the top because there it just looked wrong. Problem with that button is: I can't find a good way to make it appear three-state (off/on/automatic), and with your suggestion about having it on per default (automatic), flash it when it takes too long and then the user can click on it (on) to mark all or click on it again to turn it off completely (off). Also since that button is in the non-client area of the window, tooltips won't work there so we can't even show a hint about what that button would do or what state it's in.

for the selection marks there's a 1.5 second timeout. You can maybe see it when you double-click on a word in your large log file: you should see green marks in the scrollbar for every match of that word, but only up to the line where the search stops after 1.5 seconds. There was a time when the find marks in the find dialog also had a timeout, but I thought that when using the find dialog it wouldn't matter if it takes longer to mark all the matches.

wmjordan commented 3 years ago

That's really challenging, if there's no tool tip for that button, that an ordinary user could have little idea about what that button does.

when using the find dialog it wouldn't matter if it takes longer to mark all the matches

That is exactly the problem now since the procedure runs at the foreground. If it is in the background, the user experience may be a little better. When dealing large log files which are continuously updating, each search operation requires the document-wide highlight procedure being run again and again. That may be the pain when each delays add up together.

wmjordan commented 3 years ago

Shall we place this issue into a bigger picture--large document mode?

A great editor as far as I know, named EmEditor, has special support for large documents. When we analyze large log files, in many cases we actually do not need to view the whole document, we are interested in the end of the file, that is, part of the document.

Large document controller

If BowPad supports opening large documents, maybe there can be a button or an extra checkbox in the Open File dialog to specify "Large Document Mode" and provide a special set of commands and options in a large document view in the Ribbon.