reveal active line into view only when it is not triggered by view restore.

This commit is contained in:
rebornix 2020-03-27 14:50:00 -07:00
parent 10f5103a12
commit c2c74e602d
2 changed files with 19 additions and 1 deletions

View file

@ -130,7 +130,12 @@ export class CodeCell extends Disposable {
}
}));
this._register(templateData.editor!.onDidChangeCursorSelection(() => {
this._register(templateData.editor!.onDidChangeCursorSelection((e) => {
if (e.source === 'restoreState') {
// do not reveal the cell into view if this selection change was caused by restoring editors...
return;
}
const primarySelection = templateData.editor!.getSelection();
if (primarySelection) {

View file

@ -180,6 +180,19 @@ export class StatefullMarkdownCell extends Disposable {
}
}));
this.localDisposables.add(this.editor!.onDidChangeCursorSelection((e) => {
if (e.source === 'restoreState') {
// do not reveal the cell into view if this selection change was caused by restoring editors...
return;
}
const primarySelection = this.editor!.getSelection();
if (primarySelection) {
this.notebookEditor.revealLineInView(this.viewCell, primarySelection!.positionLineNumber);
}
}));
let cellWidthResizeObserver = getResizesObserver(this.templateData.editingContainer!, dimension, () => {
let newWidth = cellWidthResizeObserver.getWidth();
let realContentHeight = this.editor!.getContentHeight();