diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index e37383c49327405eae78d17e021c6444bf3c2fdf..0d990d07102d537af00f60636fac6675880518c6 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -766,10 +766,14 @@ export class CommandCenter { return; } + const selectionsBeforeRevert = textEditor.selections; + const visibleRangesBeforeRevert = textEditor.visibleRanges; const result = applyLineChanges(originalDocument, modifiedDocument, changes); const edit = new WorkspaceEdit(); edit.replace(modifiedUri, new Range(new Position(0, 0), modifiedDocument.lineAt(modifiedDocument.lineCount - 1).range.end), result); workspace.applyEdit(edit); + textEditor.selections = selectionsBeforeRevert; + textEditor.revealRange(visibleRangesBeforeRevert[0]); await modifiedDocument.save(); }