vprimachenko / Sublime-Colorcoder

Semantic highlight for Sublime Text
290 stars 25 forks source link

Colorcoder breaks the undo stack, and it makes Sublime undo letter by letter #38

Closed Zequez closed 9 years ago

Zequez commented 9 years ago

I recently noticed that when I Ctrl+Z Sublime undo letter by letter. Of course this is pretty frustrating. The problem stops if you remove this extension. I also tried on a brand new Sublime installation (portable), without any extra extensions (besides the package manager), and after installing Colorcoder, this issue surfaces again.

I don't know Python. Sorry.

vprimachenko commented 9 years ago

uhm, yeah, thats an artifact of how the new, faster highlighting method works, i will and an option to switch the highlighting methods, which will, in result, restore the default undo behaviour, but the highlighting may be somewhat slower

dungsaga commented 9 years ago

I'm curious to see how this new highlighting method works. Was it added a few days ago? Can you give a quick summary of this?

vprimachenko commented 9 years ago

it was added quite a while ago in 4e113570d382d86308b67710ce0b16c689ecc892

The basic idea is: in absence of an pause/resumeRedraw-like low-level api i abused the sublime_api.view_begin_edit and sublime_api.view_end_edit functions to pause the editor updates while doing the highlighting loop, so instead of doing 256 buffer redraws sublime is doing only one. This change did lower the highlighting times to one fourth for large (10000+ lines) files.

The side effect was: said functions interrupt undo-stack merging, thus a.o. making undo/redo work letter by letter.

Tbh i never actually realized this effect until this issue was posted, probably bc this behaviour was slowly introduced to me when doing benchmarks of both highlighting methods, so i never had the "wait, i just broke something" moment

vprimachenko commented 9 years ago

@Zequez set use_fast_highlighting_but_undo_typing_letterwise to false and enjoy.

Zequez commented 9 years ago

Haha cool, thanks man! I was thinking, there could be a third hybrid option: use fast highlighter for huge files, and slow highlighter for regular files.