Skip to content

Diff view crash/failure #310382

@OldStarchy

Description

@OldStarchy

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.116.0 (user setup)
  • OS Version: Windows_NT x64 10.0.26100

There is a bug in this section of code (approximately) that origLine is sometimes 0, causing areLinesSimilar to be called with an undefined.

for (extendToTop = 0; extendToTop < linesAbove; extendToTop++) {
const origLine = move.original.startLineNumber - extendToTop - 1;
const modLine = move.modified.startLineNumber - extendToTop - 1;
if (origLine > originalLines.length || modLine > modifiedLines.length) {
break;
}
if (modifiedSet.contains(modLine) || originalSet.contains(origLine)) {
break;
}
if (!areLinesSimilar(originalLines[origLine - 1], modifiedLines[modLine - 1], timeout)) {
break;
}
}

I'm not sure of the exact conditions, but the code samples below trigger it.

Steps to Reproduce:

  1. Stage a file with this content
    <UserControl x:Class="abc.def.ghi"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                mc:Ignorable="d"
                Background="{DynamicResource SomeColor}"
                d:DataContext="{d:DesignInstance abcd:Efgh, d:IsDesignTimeCreatable=False}"
                d:DesignHeight="600" d:DesignWidth="800">
    </UserControl>
  2. Modify the file to this content
     <UserControl
         x:Class="abc.def.ghi"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         mc:Ignorable="d"
         Background="{DynamicResource SomeColor}"
         d:DataContext="{d:DesignInstance abcd:Efgh, d:IsDesignTimeCreatable=False}"
         d:DesignHeight="600"
         d:DesignWidth="800"
     >
     </UserControl>
  3. Open the diff for unstaged changes (open the file from the "Changes" list in the source control view)
  4. diff does not load

The "Window" output window shows

2026-04-16 11:26:12.390 [error] [Window] Cannot read properties of undefined (reading 'trim'): TypeError: Cannot read properties of undefined (reading 'trim')
    at os (vscode-file://vscode-app/c:/Users/OldStarchy/AppData/Local/Programs/Microsoft%20VS%20Code/41dd792b5e/resources/app/out/vs/editor/common/services/editorWebWorkerMain.js#editorWorkerService:424:3486)
    at hl (vscode-file://vscode-app/c:/Users/OldStarchy/AppData/Local/Programs/Microsoft%20VS%20Code/41dd792b5e/resources/app/out/vs/editor/common/services/editorWebWorkerMain.js#editorWorkerService:424:2727)
    at ss (vscode-file://vscode-app/c:/Users/OldStarchy/AppData/Local/Programs/Microsoft%20VS%20Code/41dd792b5e/resources/app/out/vs/editor/common/services/editorWebWorkerMain.js#editorWorkerService:423:6025)
    at $n.computeMoves (vscode-file://vscode-app/c:/Users/OldStarchy/AppData/Local/Programs/Microsoft%20VS%20Code/41dd792b5e/resources/app/out/vs/editor/common/services/editorWebWorkerMain.js#editorWorkerService:425:2267)
    at $n.computeDiff (vscode-file://vscode-app/c:/Users/OldStarchy/AppData/Local/Programs/Microsoft%20VS%20Code/41dd792b5e/resources/app/out/vs/editor/common/services/editorWebWorkerMain.js#editorWorkerService:425:1602)
    at r.computeDiff (vscode-file://vscode-app/c:/Users/OldStarchy/AppData/Local/Programs/Microsoft%20VS%20Code/41dd792b5e/resources/app/out/vs/editor/common/services/editorWebWorkerMain.js#editorWorkerService:429:3664)
    at r.$computeDiff (vscode-file://vscode-app/c:/Users/OldStarchy/AppData/Local/Programs/Microsoft%20VS%20Code/41dd792b5e/resources/app/out/vs/editor/common/services/editorWebWorkerMain.js#editorWorkerService:429:3515)
    at _n._handleMessage (vscode-file://vscode-app/c:/Users/OldStarchy/AppData/Local/Programs/Microsoft%20VS%20Code/41dd792b5e/resources/app/out/vs/editor/common/services/editorWebWorkerMain.js#editorWorkerService:402:65032)
    at Object.handleMessage (vscode-file://vscode-app/c:/Users/OldStarchy/AppData/Local/Programs/Microsoft%20VS%20Code/41dd792b5e/resources/app/out/vs/editor/common/services/editorWebWorkerMain.js#editorWorkerService:402:64530)
    at Mr._handleRequestMessage (vscode-file://vscode-app/c:/Users/OldStarchy/AppData/Local/Programs/Microsoft%20VS%20Code/41dd792b5e/resources/app/out/vs/editor/common/services/editorWebWorkerMain.js#editorWorkerService:402:63316)

Which I have traced to the above mentioned line of code and scenario.

Setting a breakpoint on line 210 above yields this

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions