🐛 Update GetErrorsTool to handle Windows drive letter casing#320053
🐛 Update GetErrorsTool to handle Windows drive letter casing#320053Wangmz-1211 wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates GetErrorsTool path/URI matching to correctly associate diagnostics on Windows when the drive letter casing differs, and adds regression tests for both direct diagnostics lookup and full tool invocation output.
Changes:
- Switch URI parent/equality checks to
extUriBiasedIgnorePathCaseto tolerate case differences in Windows paths. - Add Windows-only tests validating diagnostics matching and tool output when drive letter casing differs.
- Extend the test workspace setup with a Windows-drive URI document for the new scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| extensions/copilot/src/extension/tools/node/getErrorsTool.tsx | Adjusts URI equality/parent checks to be case-insensitive (biased) so Windows drive-letter casing mismatches still match diagnostics. |
| extensions/copilot/src/extension/tools/node/test/getErrorsTool.spec.tsx | Adds Windows-specific regression tests and registers a Windows-drive document in the test workspace. |
| test.skipIf(!isWindows)('getDiagnostics - matches Windows file path with different drive letter casing', () => { | ||
| const diagnostic = { | ||
| message: 'Drive letter casing diagnostic', | ||
| range: new Range(0, 6, 0, 11), | ||
| severity: DiagnosticSeverity.Error | ||
| }; | ||
| diagnosticsService.setDiagnostics(upperCaseDriveFile, [diagnostic]); | ||
|
|
||
| const results = tool.getDiagnostics([{ uri: lowerCaseDriveFile, range: undefined }]); | ||
|
|
||
| expect(results).toEqual([ | ||
| { uri: upperCaseDriveFile, diagnostics: [diagnostic] } | ||
| ]); | ||
| }); |
| const upperCaseDriveDoc = createTextDocumentData(upperCaseDriveFile, 'const drive = "C";\n', 'ts').document; | ||
|
|
||
| collection.define(IWorkspaceService, new SyncDescriptor(TestWorkspaceService, [[workspaceFolder], [tsDoc1, tsDoc2, jsDoc, noErrorDoc, eslintErrorDoc, emptyLineErrorDoc]])); | ||
| collection.define(IWorkspaceService, new SyncDescriptor(TestWorkspaceService, [[workspaceFolder], [tsDoc1, tsDoc2, jsDoc, noErrorDoc, eslintErrorDoc, emptyLineErrorDoc, upperCaseDriveDoc]])); |
| import { Disposable } from '../../../util/vs/base/common/lifecycle'; | ||
| import { ResourceSet } from '../../../util/vs/base/common/map'; | ||
| import { isEqualOrParent } from '../../../util/vs/base/common/resources'; | ||
| import { extUriBiasedIgnorePathCase } from '../../../util/vs/base/common/resources'; |
| for (const path of nonNotebookPaths) { | ||
| // we support file or folder paths | ||
| if (isEqualOrParent(resource, path.uri)) { | ||
| if (extUriBiasedIgnorePathCase.isEqualOrParent(resource, path.uri)) { |
| const isExactMatch = extUriBiasedIgnorePathCase.isEqual( | ||
| resource, | ||
| path.uri, | ||
| ); |
|
@microsoft-github-policy-service agree |
|
I disagree that we should always ignore the path casing |
A new function The new function works for Windows only, and change only the drive letter to lowercase. This avoids always ignoring path casing. |
20b1d16 to
c748769
Compare
…I matching (Issue microsoft#319858) Fix with an explicit normalizeDriveLetter() that lower-cases only the drive letter component (e.g. C: → c:) before comparison, then uses the case-sensitive isEqual/isEqualOrParent helpers. This matches the Windows semantics where the drive letter is case-insensitive but the rest of the path may not be (see microsoft#319858). Add a dedicated unit-test suite covering all branches of normalizeDriveLetter: non-Windows identity, uppercase/lowercase drive letters, path components beyond the drive, short paths, root paths, UNC-style paths, and non-letter characters at the drive position.
c748769 to
cd65ddf
Compare
Fix #319858
This pull request updates the
GetErrorsToolto improve handling of file path comparisons on Windows, specifically addressing differences in drive letter casing. The main changes ensure that file and folder path matching is case-insensitive where appropriate, and new tests are added to verify this behavior.Path Comparison Improvements:
Updated
getErrorsTool.tsxto useextUriBiasedIgnorePathCase.isEqualOrParentandisEqualfor path comparisons, ensuring case-insensitive matching of file and folder paths, which is especially important on Windows systems.Testing Enhancements:
Added Windows-specific test cases in
getErrorsTool.spec.tsxto verify that diagnostics are correctly matched even when the drive letter casing differs (e.g.,C:vsc:). These tests are conditionally run only on Windows.These changes improve cross-platform reliability and correctness of diagnostic retrieval in the Copilot extension.