-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Fix auto scroll to last line after update not working #8782
Fix auto scroll to last line after update not working #8782
Conversation
On |
The cause of the problem is
Would have solved the issue but it's inaccessible here. Thank you for working on it. |
What do you mean by "it's inaccessible here" ? The modified place in the code of this PR? |
Would make |
Tested your PR with langs.model.xml (line wrap enabled). |
With word wrap and "Scroll to the last line after update" enabled, I edited the langs.model.xml on Notepad, then switched to Notepad++ and it did scroll to the end of the file. Compare to the behaviour without the PR, which keeps the scroll where it was before switching back to Notepad++. If you are referring to it not completely scrolling to the last line, I can confirm that it happens, and it's not due to the part of the code that scrolls to the end, but to the word wrap itself not scrolling correctly. I've been looking into it (on and off), but have yet to find a solution. The behaviour is the following: if there is one extra line (due to wrapping) on the visible text after scrolling to the end, then the scroll will be wrong by one line. If there's two extra lines, then it'll be wrong by two lines, etc. |
I have noticed that too but assumed it was not related to Another point: |
@Yaron10 |
@Yaron10 Yes, the word wrap scroll not working correctly was present in at least version 7.7. I haven't tested any version before that. |
I'll do that later today.
Thanks for testing. |
Please edit Open any file. EDIT: |
Strange, still can't replicate the problem. With this PR, word wrap enabled, File Status Auto-Detection -> Enable for all opened files ( or just Enable, but keep the focus on the file that will be edited), Scroll to the last line after update enabled, and varying the sizes of the second view. The two behaviours I see are: scroll to the last line of the .js file (which is an empty line), or, if there are wrapped lines, the problem I spoke about in a previous comment occurs. EDIT: the scroll doesn't happen if the NPP window was minimized, even though the line is selected and the code runs. Probably something else that prevents scrolling when the window appears after being minimized. |
Did you try it with a not-maximized window? |
Yes, I followed the steps you described. |
I've downloaded a fresh portable NPP (x32). And this is the position I get after externally modifying the file: Windows 7. |
Ah, that seems to be the issue with wrapping that I commented on before when replying to donho.
In your case, you have more or less 20 lines added by the wrap in your visible window, right? 223 total lines minus 20 wrapped, and you get line 203 at the bottom. It's also probably flickering from your position, then to the end, and then to the final scroll position (203). That last scroll is the word wrap scroll, which as I said, is still wrong and I haven't been able to find out why yet. Right now this PR only fixes the scroll to the end never happening, and it'll also work correctly if in the final view there are no wrapped lines. |
OK. :) It should be interesting to test it with "goToPos(getDocumentLength())" (obviously this isn't the actual code). |
@jofon Here is how I test: |
Replacing Can you try it? If it's important that the caret should be at the beginning of the last line, you can add |
And here I was playing around with the wrapcount of the visible lines... |
Great. Thanks for testing. The following code also fixes the problem.
I'd suggest to let @donho decide which should be used before committing any further changes. Another question for @donho: should we make |
The cause of the main problem (the visible lines do not change at all) is In
In
or:
|
This fix comes from the suggestion of this thread: notepad-plus-plus#8782 (comment) Fix notepad-plus-plus#8477, fix notepad-plus-plus#8214
Thank you for committing it. I'd also like to thank you for opening this PR.
I didn't look at that. |
This fix comes from the suggestion of this thread: notepad-plus-plus#8782 (comment) Fix notepad-plus-plus#8477, fix notepad-plus-plus#8214
When using the "Scroll to the last line after update" setting with Word wrap, the screen was not scrolling down to the last line. It would simply flicker down to the end, and come back to the previous scroll location.
Before version 7.8.2 (including), it would scroll to what would be the last line if Word Wrap weren't active (example: 50 lines, with 1 added line from word wrap, would result in a scroll to line 49).
This pull request fixes the issue by saving the location after the scroll to the end is done, which prevents further operations from restoring a previous position.
Fixes #8477 and fixes #8214