undoStopBefore:false in TextEditor.edit stopped working in 1.18
Cardinal90 opened this issue · 2 comments
- VSCode Version: 1.18.0
- OS Version: Windows 10
Steps to Reproduce:
I am the author of this extension. The gif on the extension page clearly shows what it does - it modifies text on every keystroke when you have multiple ranges selected. To prevent unnecessary undo stops I pass
{
undoStopAfter: false,
undoStopBefore: false
}
to the TextEditor.Edit method, which worked before.
Since 1.18 VSCode creates two undo steps for every keystroke. I traced the problem to #29036 and the commit that fixes it. That commit introduces the concept of EditOperationType
to create undo stops between different types of edits. What happens is every character is typed with operation type Typing
, and then my extension does its work with operation type Other
. That creates two unnecessary undo stops, while I clearly indicate that I don't need any by passing undoStopBefore: false
.
Reproduces without extensions: Yes
@Cardinal90 Is this still a real problem for your extension? I have to say that I don't really know how to tackle this issue given the work from #29036
Well, it still requires two undo actions instead of one in most cases and one undo per symbol in case of ALLCAPS (which is almost nonexistent in my personal practice). I found some workarounds, so it's not a big problem anymore. The extension is very much usable and does not break undo/redo history.
The fact that undoStopBefore: false
doesn't work as expected is unfortunate. But it seems to be a rare scenario, so it's probably not worth it to tackle this just to fix my issue.