Skip to content

Commit 2c620aa

Browse files
authored
Fix microsoft#172568. Reveal range avoid changing primary selection. (microsoft#172580)
* Fix microsoft#172568. Reveal range avoid changing primary selection. * Fix problems panel.
1 parent 79d10f9 commit 2c620aa

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
11591159
if (selection) {
11601160
cell.updateEditState(CellEditState.Editing, 'setOptions');
11611161
cell.focusMode = CellFocusMode.Editor;
1162-
await this.revealLineInCenterIfOutsideViewportAsync(cell, selection.startLineNumber);
1162+
await this.revealRangeInCenterIfOutsideViewportAsync(cell, new Range(selection.startLineNumber, selection.startColumn, selection.endLineNumber || selection.startLineNumber, selection.endColumn || selection.startColumn));
11631163
} else if (options?.cellRevealType === CellRevealType.NearTopIfOutsideViewport) {
11641164
await this._list.revealCellAsync(cell, CellRevealType.NearTopIfOutsideViewport);
11651165
} else {
@@ -1170,16 +1170,13 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
11701170
if (editor) {
11711171
if (cellOptions.options?.selection) {
11721172
const { selection } = cellOptions.options;
1173-
editor.setSelection({
1174-
...selection,
1175-
endLineNumber: selection.endLineNumber || selection.startLineNumber,
1176-
endColumn: selection.endColumn || selection.startColumn
1177-
});
1173+
const editorSelection = new Range(selection.startLineNumber, selection.startColumn, selection.endLineNumber || selection.startLineNumber, selection.endColumn || selection.startColumn);
1174+
editor.setSelection(editorSelection);
11781175
editor.revealPositionInCenterIfOutsideViewport({
11791176
lineNumber: selection.startLineNumber,
11801177
column: selection.startColumn
11811178
});
1182-
await this.revealLineInCenterIfOutsideViewportAsync(cell, selection.startLineNumber);
1179+
await this.revealRangeInCenterIfOutsideViewportAsync(cell, editorSelection);
11831180
}
11841181
if (!cellOptions.options?.preserveFocus) {
11851182
editor.focus();

src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export class CodeCell extends Disposable {
269269
this.onCellEditorHeightChange(contentHeight);
270270
}
271271
const lastSelection = selections[selections.length - 1];
272-
this.notebookEditor.revealLineInViewAsync(this.viewCell, lastSelection.positionLineNumber);
272+
this.notebookEditor.revealRangeInViewAsync(this.viewCell, lastSelection);
273273
}
274274
}));
275275
}

0 commit comments

Comments
 (0)