Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

ViewportStart.update() crashes with Cannot read properties of undefined (reading 'getViewLineMinColumn') when called with startLineNumber = 0. This occurs when getLinesViewportData() returns line 0 (e.g., all lines hidden or empty view), causing getIndexOf(-1) to return undefined, leading to modelLineProjections[NaN] access.

Changes

  • Added bounds validation in ViewportStart.update() to early-return when startLineNumber < 1 or startLineNumber > lineCount
  • Added regression test for setViewport with invalid line numbers
public update(viewModel: IViewModel, startLineNumber: number): void {
    if (startLineNumber < 1 || startLineNumber > viewModel.getLineCount()) {
        return;
    }
    // ...
}
Original prompt

This section details on the original issue you should resolve

<issue_title>[Unhandled Error] Cannot read properties of undefined (reading 'getViewLineMinColumn')</issue_title>
<issue_description>Issue created from VS Code Errors Analysis Dashboard

Error Bucket

a4930d15-126a-0fda-da7e-400d10c6a1cd

Error Message

Cannot read properties of undefined (reading 'getViewLineMinColumn')

Stack Trace

TypeError: Cannot read properties of undefined (reading 'getViewLineMinColumn')
at Yts.getViewLineMinColumn (file:/Users/cloudtest/vss/_work/1/s/src/vs/editor/common/viewModel/viewModelLines.ts:739:61)
at iis.getLineMinColumn (file:/Users/cloudtest/vss/_work/1/s/src/vs/editor/common/viewModel/viewModelImpl.ts:769:21)
at A5i.update (file:/Users/cloudtest/vss/_work/1/s/src/vs/editor/common/viewModel/viewModelImpl.ts:1289:125)
at iis.setViewport (file:/Users/cloudtest/vss/_work/1/s/src/vs/editor/common/viewModel/viewModelImpl.ts:745:22)
at Object.renderText (file:/Users/cloudtest/vss/_work/1/s/src/vs/editor/browser/view.ts:580:28)
at Object.renderText (file:/Users/cloudtest/vss/_work/1/s/src/vs/editor/browser/view.ts:520:22)
at (file:/Users/cloudtest/vss/_work/1/s/src/vs/editor/browser/view.ts:857:46)
at func (file:/Users/cloudtest/vss/_work/1/s/src/vs/editor/browser/view.ts:790:9)
at safeInvokeNoArg (file:/Users/cloudtest/vss/_work/1/s/src/vs/editor/browser/view.ts:857:14)
at $2e.t [as g] (file:/Users/cloudtest/vss/_work/1/s/src/vs/editor/browser/view.ts:840:9)

Details

Property Value
Version 1.107.1
Commit 994fd12f
Last Seen 2025-12-18T23:59:48.224Z
Total Hits 2.2M
Affected Users 52.1K
Platforms Linux, Mac, Windows
Product VSCode

This issue was automatically created from the VS Code Errors Dashboard</issue_description>

<agent_instructions>analyze the unhandled error, based on the callstack and its deminified source (with the commit hash), figure out how or what scenarios may trigger the error, propose possible fixes, and then implement the best option to fix it.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix unhandled error: reading 'getViewLineMinColumn' Fix undefined error in getViewLineMinColumn when viewport has invalid line numbers Jan 12, 2026
Copilot AI requested a review from bryanchen-d January 12, 2026 22:50
@bpasero bpasero requested a review from hediet January 13, 2026 06:17
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