notebook: fix unused cell lookup and broken selection deduplication (#305105)

notebook: remove dead code, fix redundant output search, and fix broken selection dedup

Co-authored-by: Raymond Zhao <7199958+rzhao271@users.noreply.github.com>
This commit is contained in:
xingsy97
2026-03-27 23:36:46 +08:00
committed by GitHub
parent 9685f8d8ee
commit 9c566819ae
2 changed files with 4 additions and 3 deletions

View File

@@ -3058,20 +3058,20 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
return;
}
this.viewModel?.viewCells.find(cell => cell.handle === value.cellInfo.cellHandle);
const viewIndex = this._list.getViewIndex(cell);
if (viewIndex === undefined) {
return;
}
if (cell.outputsViewModels.indexOf(key) < 0) {
const outputIndex = cell.outputsViewModels.indexOf(key);
if (outputIndex < 0) {
// output is already gone
removedItems.push(key);
return;
}
const cellTop = this._list.getCellViewScrollTop(cell);
const outputIndex = cell.outputsViewModels.indexOf(key);
const outputOffset = cell.getOutputOffset(outputIndex);
updateItems.push({
cell,

View File

@@ -159,6 +159,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
const handles: number[] = [];
cellRangesToIndexes(this._selectionCollection.selections).map(index => index < this.length ? this.cellAt(index) : undefined).forEach(cell => {
if (cell && !handlesSet.has(cell.handle)) {
handlesSet.add(cell.handle);
handles.push(cell.handle);
}
});