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

As of v8.6.3 a search/replace that results in a link no longer gets auto-underlined #14864

Closed
mkupper opened this issue Mar 15, 2024 · 1 comment

Comments

@mkupper
Copy link

mkupper commented Mar 15, 2024

Description of the Issue

I was using v8.6.4 and had

xyzzy

I did a search/replace:
Search: ^xyzzy
Replace: https://notepad-plus-plus.org/

https://notepad-plus-plus.org/ appeared but it was not underlined and was not clickable. If you then scroll the page or make any changes then https://notepad-plus-plus.org/ gets underlined and is clickable.

With Notepad++ v8.6.2 and earlier the link was underlined immediately after the search/replace. A change related to v8.6.3 RC1 on out broke this.

The exact search/replace does not matter as long as it's one that creates a file:// or https?:// style string of text that is normally underlined and clickable.

The https://community.notepad-plus-plus.org/topic/25577/link-underlines-no-longer-auto-applied-on-search-replace forum thread has thoughts about what caused this change in behavior.

molsonkiko added a commit to molsonkiko/notepad-plus-plus that referenced this issue Mar 19, 2024
… All

Fix notepad-plus-plus#13916
Fix notepad-plus-plus#14864 (URLs are now automatically highlighted after a find/replace action)

previously Notepad_plus::addHotSpot used ScintillaEditView::getVisibleStartAndEndPosition
    to get the start and end positions to scan for URLs,
    which sets startPos to the start of the first line in view
    and endPos to the end of the last line in view.
This means that when a very long line is in view, URL scanning can take an extremely long time,
    and in some unusual cases can lead to loading or even scrolling a document to take minutes.
This commit fixes this issue by ensuring that, if only one line is in view,
    startPos and endPos are clamped to the true first and last characters visible.
    In all other cases, startPos and endPos are set using the same rules as before.
In addition to eliminating insane latency in the most extreme cases,
    this commit also greatly improves the vertical scroll rate on *all*
    word-wrapped documents when only one very long line is in view.

Because of the above-described change, horizontal scrolling now triggers URL scanning
    *if there is one line in view* (since it is still unnecessary when multiple lines are in view).
    Horizontal scrolling is still about as fast as it was before
    whether there was one line in view or multiple.

An unrelated quality-of-life improvement: this commit turns off URL scanning
    while Notepad++ is shutting down, to help reduce shutdown time.

A SIGNIFICANT DISADVANTAGE OF THIS CHANGE:
Ordinarily, when part of a URL is visible, the entire URL (including the parts not visible)
    are highlighted, and thus, clicking the link will always go to the same URL.
Because of the changes in this commit, when only a single line is in view,
    if only part of a URL is visible, only that part will be highlighted.
    For example, if only the "https://f" of "https://foo.bar" is visible
    in a word-wrapped long line, clicking the link would go to "https://f" rather than the full URL.

To test this commit:
1. download the test file from the original message of notepad-plus-plus#13916
2. open the test file in Notepad++. Verify that it takes only a short time to open (not minutes).
3. Turn ON word wrap. Try scrolling up and down. Verify that scrolling does not cause long lag.
4. Turn OFF word wrap. Try scrolling side to side. Verify that the scrolling does not cause long lag.
5. try replacing all instances of ":" with " https://".
6. Verify that URLs are highlighted as you scroll through the document.
    Once again, lag should not be too bad.
7. Turn ON word wrap. Verify that URLs are highlighted as you scroll through the document.
8. Save the test document with the URLs.
9. Close and reopen Notepad++. Verify that load speed is acceptable.
10. Repeat steps 3, 4, and 7.
11. Test URL scanning for a document with multiple lines. Make sure it works as normal.
12. Try creating a document with multiple lines that each have many characters (say, 100 lines with 200 thousand characters each).
13. Verify that horizontal scrolling is not too slow when word wrap is turned *off* and only one line is in view.
14. Verify that vertical scrolling is not too slow when word wrap is turned *on* and only one line is in view.
@molsonkiko
Copy link
Contributor

This issue appears to be fixed by this commit. Give it a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants