Skip to content

Comments

Fix ViewModel issue where all lines were hidden#296709

Merged
alexdima merged 11 commits intomainfrom
alexd/comparable-sparrow
Feb 21, 2026
Merged

Fix ViewModel issue where all lines were hidden#296709
alexdima merged 11 commits intomainfrom
alexd/comparable-sparrow

Conversation

@alexdima
Copy link
Member

@alexdima alexdima commented Feb 21, 2026

Fixes #293365

Copilot AI review requested due to automatic review settings February 21, 2026 08:45
@alexdima alexdima self-assigned this Feb 21, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an edge case in the editor ViewModel’s constant-time prefix sum implementation where getIndexOf could return an invalid index (e.g. when all values are zero), which can result in all lines being treated as hidden.

Changes:

  • Fix ConstantTimePrefixSumComputer.getIndexOf to handle sums that are not present in _indexBySum (notably when total sum is 0).
  • Fix _ensureValid trimming logic to avoid invalid _indexBySum.length when the values array is empty.
  • Expand the prefix sum test suite to run the same behavioral assertions against both PrefixSumComputer and ConstantTimePrefixSumComputer.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/vs/editor/test/common/viewModel/prefixSumComputer.test.ts Refactors/expands tests to validate both prefix-sum implementations across many scenarios (zeroes, inserts/removes, mutations).
src/vs/editor/common/model/prefixSumComputer.ts Adds a safety fallback in ConstantTimePrefixSumComputer.getIndexOf and fixes _indexBySum.length trimming for empty inputs.

alexdima and others added 7 commits February 21, 2026 11:40
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… areas

When an edit (delete/undo) removes or merges the only visible line(s) into
hidden lines, the view model could end up with zero visible lines, causing
downstream crashes (e.g. 'Not supported' from HiddenModelLineProjection).

The safety check in acceptVersionId only caught the case where exactly 1
hidden line remained. Generalize it to detect when getViewLineCount() === 0
and minimally restore visibility by making just the first line visible,
preserving the caller's intended hidden areas as much as possible.
When hidden area decorations drift via AlwaysGrowsWhenTypingAtEdges
stickiness, _constructLines(resetHiddenAreas=false) — triggered by
tab size or wrapping changes — can rebuild projections with all lines
hidden.

Extract _ensureAtLeastOneVisibleLine() shared by both _constructLines
and acceptVersionId.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

alexdima and others added 2 commits February 21, 2026 13:10
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@alexdima alexdima merged commit 9c99e8f into main Feb 21, 2026
19 checks passed
@alexdima alexdima deleted the alexd/comparable-sparrow branch February 21, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Unhandled Error] Cannot read properties of undefined (reading 'getViewLineMinColumn')

2 participants