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

Debounce mod events to avoid being blocked on each keypress (esp. at large vertical blocks) #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

eugenesvk
Copy link

This PR adds debouncing to avoid being blocked on each editing keypress:
While editing large vertical blocks the plugin struggles to do a lot of inserts needed to vertically align many lines. This makes typing close to impossible since the plugin tries to realign on every width-changing edit.
With debouncing, the realignment only starts after a user-configurable delay has passed after the last edit/selection change operation, so it doesn't block continuous typing

I've tried the async alternative, which would also have solved this issue even better (as then you'd have no blocking at all and could continue to type while all the other lines are being aligned in the background), but then various editing operations affect the lines being aligned (e.g., while deleting a char in line 1 while the async operations is aligning line 50, you could accidentally delete something in line 50)
Do you know if it's possible to restructure your plugin somehow to avoid live edits to affect subsequent lines directly?

P.S.

  • I've also upped the plugin host version to 3.8 to avoid having to deal with the old python, but this would need the plugin to have a separate tag/branch to support ST 4 since that's the version choice is only available since ST 4050

  • the debouncing code is a modification of code from gitgutter, so added their license. I'm also running your alignment code directly inside the debouncer instead of calling a cleanly separated TextCommands as some of the debouncing comments suggest since on another plugin calling TextCommands broke find highlighting, so didn't attempt it here

On large vertical blocks the plugin struggles to do a lot of inserts needed to vertically align many lines. This makes typing close to impossible since the plugin tries to realign on every width-changing edit.
With debouncing, the realignment only starts after a user-configurable delay has passed after the last edit/selection change operation, so it doesn't block continuous typing
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.

1 participant