Debounce mod events to avoid being blocked on each keypress (esp. at large vertical blocks) #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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