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

Make linewrapping plugin recompute breaks before scrolling #1190

Merged
merged 1 commit into from
Nov 7, 2022

Conversation

ColonelPhantom
Copy link
Contributor

This ensures that having linewrapping enabled does not break projectsearch. I have also opened an issue for this, but in the plugins repo: lite-xl/lite-xl-plugins#148

local old_scroll_to_make_visible = DocView.scroll_to_make_visible
function DocView:scroll_to_make_visible(line, col)
LineWrapping.update_docview_breaks(self)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like overriding DocView:scroll_to_line is enough to fix the issue with the projectsearch plugin. Any reason to also call LineWrapping.update_docview_breaks on DocView:scroll_to_make_visible? I'm worried that calling LineWrapping.reconstruct_breaks (which is called by update_docview_breaks) will hurt performance more since it is already been called on each update().

Otherwise the fix is good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am under the impression that update_docview_breaks will only call reconstruct_breaks if necessary, so only once. It'll check the width a few extra times, but that's relatively harmless, IMO.

I added it to the other scroll function as well in case any other plugins or modifications use it, to make sure everything is as robust as possible. One function call with an if statement is an acceptable overhead, I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some core.log testing directly on reconstruct_breaks and it was executing its code on every call, it doesn't seems to implement any state tracking for now. And adding the update breaks to scroll visible just increases the amount of times it gets called when manually scrolling the docview

Copy link
Member

@jgmdev jgmdev Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, that isn't correct... it is only been triggered now on scroll hover with the call to LineWrapping.update_docview_breaks(self) on DocView:scroll_to_make_visible

Edit: Actually I'm wrong again, should get some sleep xD

@jgmdev
Copy link
Member

jgmdev commented Nov 7, 2022

Ok merging this which is good after some play with linewrapping and its code :)

@jgmdev jgmdev merged commit 4a5851a into lite-xl:master Nov 7, 2022
takase1121 pushed a commit to takase1121/lite-xl that referenced this pull request Nov 14, 2022
takase1121 pushed a commit to takase1121/lite-xl that referenced this pull request Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants