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

Add max_threshold setting #62

Merged
merged 6 commits into from
Apr 10, 2024
Merged

Add max_threshold setting #62

merged 6 commits into from
Apr 10, 2024

Conversation

Myzel394
Copy link
Contributor

@Myzel394 Myzel394 commented Apr 4, 2024

I noticed quite some slowdown when dealing with large files and quickly jumping to the end (G) or the beginning (gg). I figured this was SmoothCursor.nvim's fault.

I added a setting to set a max threshold. If you move more than this amount of lines, there will be no animation. Tried it out in practice, after that there was no more slowdown anymore ^^

@gen740
Copy link
Owner

gen740 commented Apr 4, 2024

Thank you for your PR!

Nice idea! However, I think it shouldn't be like that. According to #11, if SmoothCursor jumps a large chunk, the cursor will skip to within a one-page range.

I ran some tests with files of 200, 1000, 10000 lines. The test was just to open and press G with fancy mode enabled, and count the sign_place action (which should be the most expensive task). The result was 573 times in all cases.

Can you provide more details about the situation where the slowdown occurred?

@Myzel394
Copy link
Contributor Author

Myzel394 commented Apr 4, 2024

Can you provide more details about the situation where the slowdown occurred?

Yes, so I'm specifically talking about my kitty.conf file. I do use folds, so when I open it, I pretty much only see a few folds and already the end of the file. When jumping to the end of it, it's very slow.

So my assumption is, since "everything" is in the visible viewport, SmoothCursor will go through everything, including the folded lines?

While max_threshold won't fix this specific issue, I think it'd still be a good option as one might still want to disable it for idk, 10 lines or so; we can also set the default value to something like 100_000 to make sure it pretty much always runs on default config :D

@gen740
Copy link
Owner

gen740 commented Apr 8, 2024

While max_threshold won't fix this specific issue, I think it'd still be a good option

I agree with this.

Can you set default value to nil? Then I will merge this!

@Myzel394
Copy link
Contributor Author

Myzel394 commented Apr 9, 2024

All right the default value is set to nil. This will disable the max_threshold check.

I noticed that I actually did not implement this correctly! I fixed it now, now it should work as expected. I have no idea why it worked previously, as I have really tested it, but heh - at least it seems to be working now :D

@gen740
Copy link
Owner

gen740 commented Apr 10, 2024

LGTM!

@gen740 gen740 merged commit d60c199 into gen740:main Apr 10, 2024
1 check passed
@gen740
Copy link
Owner

gen740 commented Apr 10, 2024

There might be some difficulties in detecting folded lines and skipping them. Though it should be, I'm not keen on implementing it (as I rarely use folding text).

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 this pull request may close these issues.

2 participants