Skip to content

Conversation

@dmitrivMS
Copy link
Contributor

@dmitrivMS dmitrivMS commented Jan 1, 2026

Problem description

During _constructLines(), the modelLineProjections array was emptied (this.modelLineProjections = [])
While reconstructing (40+ lines of code), synchronous callbacks could fire from model operations
These callbacks tried to access modelLineProjections[index] which was empty/incomplete
Result: Cannot read properties of undefined (reading 'getViewLineMinColumn'|'getViewLineContent'|'getViewLineMaxColumn')

Potentially fixes the following issues

#284539
#283293
#283289
#283288
#283286
#283048
#233161
#213371
#213247
#198172
#283298
#283290
#240205
#240206
#232917
#246657
#175521
#161048
#260073

…e observed by events fired during model access.
Copilot AI review requested due to automatic review settings January 1, 2026 23:49
@dmitrivMS dmitrivMS added the editor-core Editor basic functionality label Jan 1, 2026
@dmitrivMS dmitrivMS requested a review from hediet January 1, 2026 23:49
@dmitrivMS dmitrivMS self-assigned this Jan 1, 2026
@dmitrivMS dmitrivMS enabled auto-merge January 1, 2026 23:49
@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Jan 1, 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 a critical race condition in ViewModelLinesFromProjectedModel._constructLines() where the modelLineProjections array was cleared and rebuilt incrementally. During reconstruction, synchronous callbacks from model operations could fire and attempt to access the incomplete array, causing "Cannot read properties of undefined" errors when calling methods like getViewLineMinColumn, getViewLineContent, or getViewLineMaxColumn.

Key Changes

  • Build projections in a local newProjections array instead of directly updating this.modelLineProjections
  • Atomically replace this.modelLineProjections only after all projections are built, preventing callbacks from observing partially updated state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

editor-core Editor basic functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants