-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Bug Description:
From time to time, the auto-save causes the editor to trim whitespace unnecessarily. Initially reported in arduino/arduino-ide#437, but I could reproduce the bug with TheiaBlueprint, Version 1.35.0 (1.35.0.98), using a JS file.
Steps to Reproduce:
Open Theia Blueprint and create a JS file with this or structurally similar content where <|>
is the current position, auto-save is on:
function foo() {
// indent<|>
}
- Press enter so the file after pressing the Enter key is the following and
<|>
is the expected cursor position:
function foo() {
// indent
<|>
}
- After pressing enter and the auto-save task, sometimes the cursor jumps back to the first column
- If you cannot reproduce it, delete the new line to have the initial state, and repeat step 1.
monaco-editor-model-sync.mp4
There is another way:
- You have to disable auto-save,
- Press enter to start a new line with the expected indentation, enable auto-save,
- The leading whitespace is removed, although it was not requested.
monaco-editor-sync.mp4
File resource receives the file change event here
this.sync(); |
Here, an invalid mtime
is compared with the stat
return !!this.version && this.version.mtime >= stat.mtime; |
Text model update is triggered with empty edits array
this.updateModel(() => StandaloneServices.get(IModelService).updateModel(this.model, value), { |
But since editor.trimAutoWhitespace
is true
, the whitespaces will be trimmed in the textModel
: https://github.com/microsoft/vscode/blob/c20740a3a29112acd9345a5e898bbfb8116c7e24/src/vs/editor/common/model/textModel.ts#L1331-L1334
Additional Information
- Operating System: macOS
- Theia Version: TheiaBlueprint, Version 1.35.0 (1.35.0.98)