Skip to content

Commit 9934264

Browse files
committed
Fixes microsoft#42783: Make sure to call TextModel._setTrackedRange when undoing
1 parent 705de3d commit 9934264

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

src/vs/editor/common/controller/oneCursor.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ export class OneCursor {
9393
viewState = new SingleCursorState(viewSelectionStart, modelState.selectionStartLeftoverVisibleColumns, viewPosition, modelState.leftoverVisibleColumns);
9494
}
9595

96-
if (this.modelState && this.viewState && this.modelState.equals(modelState) && this.viewState.equals(viewState)) {
97-
// No-op, early return
98-
return;
99-
}
100-
10196
this.modelState = modelState;
10297
this.viewState = viewState;
10398

src/vs/editor/test/browser/controller/cursor.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,43 @@ suite('Editor Controller - Regression tests', () => {
21252125

21262126
model.dispose();
21272127
});
2128+
2129+
test('issue #42783: API Calls with Undo Leave Cursor in Wrong Position', () => {
2130+
let model = createTextModel(
2131+
[
2132+
'ab'
2133+
].join('\n')
2134+
);
2135+
2136+
withTestCodeEditor(null, { model: model }, (editor, cursor) => {
2137+
editor.setSelections([
2138+
new Selection(1, 1, 1, 1)
2139+
]);
2140+
2141+
editor.executeEdits('test', [{
2142+
range: new Range(1, 1, 1, 3),
2143+
text: ''
2144+
}]);
2145+
assertCursor(cursor, [
2146+
new Selection(1, 1, 1, 1),
2147+
]);
2148+
2149+
cursorCommand(cursor, H.Undo, null, 'keyboard');
2150+
assertCursor(cursor, [
2151+
new Selection(1, 1, 1, 1),
2152+
]);
2153+
2154+
editor.executeEdits('test', [{
2155+
range: new Range(1, 1, 1, 2),
2156+
text: ''
2157+
}]);
2158+
assertCursor(cursor, [
2159+
new Selection(1, 1, 1, 1),
2160+
]);
2161+
});
2162+
2163+
model.dispose();
2164+
});
21282165
});
21292166

21302167
suite('Editor Controller - Cursor Configuration', () => {

0 commit comments

Comments
 (0)