-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Closed
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugeditor-coreEditor basic functionalityEditor basic functionalityverifiedVerification succeededVerification succeeded
Milestone
Description
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:
|ab
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 giveb|
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugeditor-coreEditor basic functionalityEditor basic functionalityverifiedVerification succeededVerification succeeded