Notebook scrolling to search result instead of selected cell (#20580)

* do not scroll to current result if there's other cell active

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
This commit is contained in:
Barbara Valdez
2022-11-04 11:05:26 -07:00
committed by GitHub
parent f8b7c32030
commit efe56eba8c
3 changed files with 7 additions and 8 deletions

View File

@@ -73,16 +73,18 @@ export abstract class CellView extends AngularDisposable implements OnDestroy, I
let elements = this.getHtmlElements();
if (elements?.length >= range.startLineNumber) {
let elementContainingText = elements[range.startLineNumber - 1];
let isCellActive = range.cell.active;
let markCurrent = new Mark(elementContainingText); // to highlight the current item of them all.
markCurrent.markRanges([{
start: range.startColumn - 1, //subtracting 1 since markdown html is 0 indexed.
length: range.endColumn - range.startColumn
}], {
className: findRangeSpecificClass,
each: function (node, range) {
// node is the marked DOM element
node.scrollIntoView({ block: 'center' });
if (isCellActive) {
// node is the marked DOM element
node.scrollIntoView({ block: 'center' });
}
}
});
}

View File

@@ -216,7 +216,7 @@ export class OutputComponent extends CellView implements OnInit, AfterViewInit {
className: findRangeSpecificClass,
each: function (node, range) {
// node is the marked DOM element
node.scrollIntoView({ behavior: 'smooth', block: 'center' });
node.scrollIntoView({ block: 'center' });
}
});
} else if (elements?.length >= range.startLineNumber) {
@@ -228,7 +228,7 @@ export class OutputComponent extends CellView implements OnInit, AfterViewInit {
className: findRangeSpecificClass,
each: function (node) {
// node is the marked DOM element
node.scrollIntoView({ behavior: 'smooth', block: 'center' });
node.scrollIntoView({ block: 'center' });
}
});
}

View File

@@ -350,9 +350,6 @@ export class NotebookEditor extends EditorPane implements IFindNotebookControlle
this._findDecorations.getCount(),
this._currentMatch
);
if (this._finder.getDomNode().style.visibility === 'visible' && this._previousMatch !== this._currentMatch) {
this._setCurrentFindMatch(this._currentMatch);
}
}
}