Skip to content

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

Merged
amunger merged 2 commits intomicrosoft:mainfrom
xingsy97:wt/notebook-cleanups
Mar 27, 2026
Merged

notebook: fix unused cell lookup and broken selection deduplication#305105
amunger merged 2 commits intomicrosoft:mainfrom
xingsy97:wt/notebook-cleanups

Conversation

@xingsy97
Copy link
Copy Markdown
Member

@xingsy97 xingsy97 commented Mar 26, 2026

Problem

Three independent issues

  1. notebookEditorWidget.ts:3061: this.viewModel?.viewCells.find(...) performs an O(n) linear scan whose result is never assigned, the cell was already resolved via the O(1) getCellByHandle() call on the previous line.

  2. notebookEditorWidget.ts:3068+3074: cell.outputsViewModels.indexOf(key) is called twice for the same key: once for an existence check and again to retrieve the index.

  3. notebookViewModelImpl.ts:163: selectionHandles getter creates a Set<number> for deduplication but never calls add(), so the Set stays empty and deduplication has no effect.

Fix

  1. Remove the unused viewCells.find() call.
  2. Cache the indexOf result and use it for both the existence check and the offset calculation. Return early when the output is gone.
  3. Add the missing handlesSet.add(cell.handle) call.

Copilot AI review requested due to automatic review settings March 26, 2026 10:08
@vs-code-engineering vs-code-engineering bot added this to the 1.114.0 milestone Mar 26, 2026
@amunger
Copy link
Copy Markdown
Collaborator

amunger commented Mar 26, 2026

thanks for the clean-up

@amunger amunger merged commit 9c56681 into microsoft:main Mar 27, 2026
28 of 29 checks passed
@xingsy97 xingsy97 deleted the wt/notebook-cleanups branch March 31, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants