Conversation
There was a problem hiding this comment.
Quick drive-by comment: this may need to be batched with the other operation to avoid creating two separate Undo steps. But the other operation is done on a timeout, which means we'd need to figure out a different fix that can occur after the '}' is typed rather than before. Maybe after the indentLine() call, we could check if the rest of the line is nothing but whitespace, and remove it if so? then the indentLine() & replaceRange() calls could be grouped together in a batch.
There was a problem hiding this comment.
How does one batch commands so that they aren't separate undo ops?
There was a problem hiding this comment.
Normally document.batchOperation(), but within Editor it looks like we call the raw cm.operation() directly instead.
There was a problem hiding this comment.
@mackenza As I suggested in IRC, maybe moving cursor to end of (whitespace-only) line before performing edit is a simpler solution.
There was a problem hiding this comment.
I will give it a look.
|
problems with git so I had to recreate my fork and thus this PR is orphaned. I will close this and open a new one for this issue. Sorry for being such a git noob ;) |
This is a PR to address #8395
I am not super happy about testing the nonWS again as is done below in the || comparison but I couldn't immediately think of a better way to do this.
As per the issue discussion, if the line has non-whitespace characters, the whitespace is not stripped.