Skip to content
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

Non-blocking find/replace actions #685

Closed
h-h-h-h opened this issue Aug 8, 2015 · 5 comments

Comments

Projects
None yet
5 participants
@h-h-h-h
Copy link
Contributor

commented Aug 8, 2015

Hello,

the work Notepad++ does triggered by the find-and-replace dialog should be done in a worker thread and should be cancelable.

This is because such actions can sometimes last very long and can even cause you to think the GUI will never respond again and to force-terminate the program. This is especially true for large files.

If there's a way to get this information, there should even be a progress bar. Alternatively, the information of the last processing time would be valuable, if it's a long one.

An optional sound after long operations would also be appreciated.


Related issue: #365


Because the find-and-replace dialog already has many buttons, probably there shouldn't be added an additional Cancel button. Because it makes sense to cancel a running action before closing the dialog, the Close button could turn into a Cancel button while an action is running.

The following image is an illustration of how the progress could be indicated. It shows the bottom of the find-and-replace dialog.

gui

The remaining time should appear as soon as enough data was gathered for a non-jumping presentation (short fixed amount of time?) and only if it's greater than or equal to 2 seconds at this point.


The developer of the PCRE2 library told me via e-mail that he is implementing an end offset feature for the functions pcre2_match() and pcre2_substitute() that would allow progress features (see issue #816). Because it would be a huge performance hit to do additional progress-related processing on every character position of the subject string, one should let the library process the string repeatedly from a start offset to an end offset and do progress-related processing between those calls. (Example: Try to match starting from offsets 0 to 100, update progress controls, try to match starting from offsets 101 to 200, and so on.)

Because the processing time of different regular expressions can differ very much, the application should first process a short range of the subject string and see whether the PCRE2 function returns quickly. If it returned quickly, the length of the ranges processed at once can be increased. This way, the length can be leveled out at a frequency of, say, 20 Hz (50 ms between GUI updates).

Old text about conversation with the developer:
When having switched to the PCRE2 library, the functions pcre2_match() and pcre2_substitute() are able to provide progress information by means of callouts. At the time of this writing (2015-09-17), it is already possible with the pcre2_match() function, and the PCRE2 developer told me via e-mail that he is considering a new callout that would perhaps make global substitution progress easier to implement when pcre2_substitute() is used.

Of course, a worker thread is still necessary, because single matches between the callouts can still last very long. (For your information: The PCRE2 developer also mentioned the match limit feature to limit the amount of work done. But I think a worker thread is the only opinion for Notepad++.)

@h-h-h-h h-h-h-h changed the title Non-blocking find actions and replace actions Non-blocking find/replace actions Aug 8, 2015

@milipili

This comment has been minimized.

Copy link
Contributor

commented Aug 8, 2015

It is already planned.

@milipili milipili added the enhancement label Aug 8, 2015

@milipili milipili added this to the 7.x (master) milestone Aug 8, 2015

@h-h-h-h

This comment has been minimized.

Copy link
Contributor Author

commented Aug 8, 2015

Great!

@ariccio

This comment has been minimized.

Copy link
Contributor

commented Aug 8, 2015

Great!

...close this issue? Or say that you will when it's implemented?

@h-h-h-h

This comment has been minimized.

Copy link
Contributor Author

commented Aug 8, 2015

There's information in this issue that is still relevant. This issue is an addition. Surely, not every detail was planned as I described it. It wasn't said where it is planned. Not in an issue? Then we would see a reference here. I expect something like that.

tonyk24 added a commit to tonyk24/notepad-plus-plus that referenced this issue Jun 6, 2017

tonyk24 added a commit to tonyk24/notepad-plus-plus that referenced this issue Jun 7, 2017

tonyk24 added a commit to tonyk24/notepad-plus-plus that referenced this issue Jun 12, 2017

tonyk24 added a commit to tonyk24/notepad-plus-plus that referenced this issue Jun 23, 2017

@garydgregory

This comment has been minimized.

Copy link

commented Nov 15, 2018

I love the think progress bar idea.

@MetaChuh MetaChuh closed this Apr 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.