Skip to content

Comments

Clamp viewport line numbers in getCompletelyVisibleViewRange#295856

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-unhandled-error-undefined-again
Closed

Clamp viewport line numbers in getCompletelyVisibleViewRange#295856
Copilot wants to merge 2 commits intomainfrom
copilot/fix-unhandled-error-undefined-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

getCompletelyVisibleViewRange() and getCompletelyVisibleViewRangeAtScrollTop() use line numbers from viewLayout.getLinesViewportData() without clamping, causing Cannot read properties of undefined (reading 'getViewLineMinColumn') when viewport data is stale after a model change (e.g., during editor input transitions triggering updateOptions → config change → mainThreadEditor reading visible ranges).

The sibling method getVisibleRangesPlusViewportAboveBelow() already clamps correctly. Applied the same Math.max(1, ...) / Math.min(this.getLineCount(), ...) pattern to both methods.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • redirector.gvt1.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=6743 --enable-crash-reporter=20c4b431-3a5f-48a4-8742-e59c04dc8e8b,no_channel --user-data-dir=/tmp/vscode-tests-1771360825840 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,8433739414279652828,12731713229849147524,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: .build/electron/code-oss .build/electron/code-oss test/unit/electron/index.js --crash-reporter-directory=/home/REDACTED/work/vscode/vscode/.build/crashes --run src/vs/editor/test/browser/viewModel/viewModelImpl.test.ts (dns block)
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=8509 --enable-crash-reporter=20c4b431-3a5f-48a4-8742-e59c04dc8e8b,no_channel --user-data-dir=/tmp/vscode-tests-1771361181084 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,10414167561713765848,5024585337175371328,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041 e_modules/.bin/sh Map --inlineSourbash --sourceMap --inlineSources sh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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

278407ff-ebf2-a32b-7ba2-246abc37bf68

Error Message

Cannot read properties of undefined (reading 'getViewLineMinColumn')

Stack Trace

    at Phs.getViewLineMinColumn (./src/vs/editor/common/viewModel/viewModelLines.ts:739:61)
    at Vhs.getLineMinColumn (./src/vs/editor/common/viewModel/viewModelImpl.ts:804:21)
    at Vhs.getCompletelyVisibleViewRange (./src/vs/editor/common/viewModel/viewModelImpl.ts:685:29)
    at Vhs.getVisibleRanges (./src/vs/editor/common/viewModel/viewModelImpl.ts:626:32)
    at _u.getVisibleRanges (./src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:563:35)
    at I4.f (./src/vs/workbench/api/browser/mainThreadEditor.ts:92:21)
    at I4.readFromEditor (./src/vs/workbench/api/browser/mainThreadEditor.ts:36:55)
    at GMs.p (./src/vs/workbench/api/browser/mainThreadEditor.ts:214:34)
    at i (./src/vs/workbench/api/browser/mainThreadEditor.ts:291:10)
    at updateProperties (./src/vs/workbench/api/browser/mainThreadEditor.ts:317:4)
    at L.C (./src/vs/base/common/event.ts:1295:12)
    at L.D (./src/vs/base/common/event.ts:1306:8)
    at L.fire (./src/vs/base/common/event.ts:1330:8)
    at cde.value (./src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:306:28)
    at L.C (./src/vs/base/common/event.ts:1295:12)
    at L.fire (./src/vs/base/common/event.ts:1326:8)
    at Gue.C (./src/vs/editor/browser/config/editorConfiguration.ts:113:20)
    at Gue.updateOptions (./src/vs/editor/browser/config/editorConfiguration.ts:174:7)
    at _u.updateOptions (./src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:442:22)
    at _u.rc (./src/vs/editor/browser/widget/codeEditor/embeddedCodeEditorWidget.ts:55:8)
    at cde.value (./src/vs/editor/browser/widget/codeEditor/embeddedCodeEditorWidget.ts:47:94)
    at L.C (./src/vs/base/common/event.ts:1295:12)
    at L.D (./src/vs/base/common/event.ts:1306:8)
    at L.fire (./src/vs/base/common/event.ts:1330:8)
    at cde.value (./src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:301:34)
    at L.C (./src/vs/base/common/event.ts:1295:12)
    at L.fire (./src/vs/base/common/event.ts:1326:8)
    at Gue.C (./src/vs/editor/browser/config/editorConfiguration.ts:113:20)
    at Gue.updateOptions (./src/vs/editor/browser/config/editorConfiguration.ts:174:7)
    at fl.updateOptions (./src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:442:22)
    at HRe.Mb (./src/vs/workbench/browser/parts/editor/textCodeEditor.ts:49:22)
    at HRe.Qb (./src/vs/workbench/browser/parts/editor/textEditor.ts:323:8)
    at HRe.setInput (./src/vs/workbench/browser/parts/editor/textEditor.ts:248:7)
    at async HRe.setInput (./src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts:106:2)
    at async Pet.S (./src/vs/workbench/browser/parts/editor/editorPanes.ts:466:3)
    at async Pet.L (./src/vs/workbench/browser/parts/editor/editorPanes.ts:259:33)
    at async Pet.openEditor (./src/vs/workbench/browser/parts/editor/editorPanes.ts:136:10)
    at async (./src/vs/workbench/browser/parts/editor/editorGroupView.ts:1260:48)

Related Information


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

<agent_instructions>follow instructions from ./.github/prompts/fix-error.prompt.md to investigate this unhandled error.</agent_instructions>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…port line numbers

Clamp viewport line numbers from viewLayout.getLinesViewportData() to the
valid range [1, getLineCount()] in getCompletelyVisibleViewRange() and
getCompletelyVisibleViewRangeAtScrollTop(). This prevents out-of-bounds
access to modelLineProjections[] when viewport data is stale after a model
change.

The sibling method getVisibleRangesPlusViewportAboveBelow() already
performs this clamping correctly.

Fixes #278407ff-ebf2-a32b-7ba2-246abc37bf68

Co-authored-by: bryanchen-d <41454397+bryanchen-d@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unhandled error reading properties of undefined Clamp viewport line numbers in getCompletelyVisibleViewRange Feb 17, 2026
Copilot AI requested a review from bryanchen-d February 17, 2026 20:49
@alexdima
Copy link
Member

Let's close in favor of #296709

@alexdima alexdima closed this Feb 21, 2026
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')

3 participants