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
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