Environment
- VSCode Version: 1.19.3
- OS Version: macOS 10.13.3
- Does this issue occur when all extensions are disabled?: Yes
Steps to Reproduce
Create an extension with the following activate function:
export async function activate(context: vscode.ExtensionContext): Promise<void> {
const editor = vscode.window.activeTextEditor;
if (!editor) return;
await editor.edit(function(editBuilder) {
editBuilder.delete(
new vscode.Range(
new vscode.Position(0, 0),
new vscode.Position(0, 2),
)
);
});
await vscode.commands.executeCommand('undo');
await editor.edit(function(editBuilder) {
editBuilder.delete(
new vscode.Range(
new vscode.Position(0, 0),
new vscode.Position(0, 1),
)
);
});
}
And run it on a text file containing:
Where | denotes the cursor position. I would expect the result to be |b but the cursor ends up in the wrong position: b|.
Here are the expected results for each of the three steps that the code does:
- The first edit should and does give
|
- Then the undo should and does give
|ab
- Then the second edit should give
|b, but does give b|
Another peculiarity that may be related is that if I undo after running that code I get a TextEditorSelectionChangeEvent with kind: keyboard even though I haven't moved the cursor. That doesn't happen with similar code that leaves the cursor in the expected position.
Environment
Steps to Reproduce
Create an extension with the following activate function:
And run it on a text file containing:
Where
|denotes the cursor position. I would expect the result to be|bbut the cursor ends up in the wrong position:b|.Here are the expected results for each of the three steps that the code does:
||ab|b, but does giveb|Another peculiarity that may be related is that if I undo after running that code I get a
TextEditorSelectionChangeEventwithkind: keyboardeven though I haven't moved the cursor. That doesn't happen with similar code that leaves the cursor in the expected position.