Skip to content

🐛 Update GetErrorsTool to handle Windows drive letter casing#320053

Open
Wangmz-1211 wants to merge 4 commits into
microsoft:mainfrom
Wangmz-1211:fix/getErrors-tool-uri-parsing
Open

🐛 Update GetErrorsTool to handle Windows drive letter casing#320053
Wangmz-1211 wants to merge 4 commits into
microsoft:mainfrom
Wangmz-1211:fix/getErrors-tool-uri-parsing

Conversation

@Wangmz-1211
Copy link
Copy Markdown

Fix #319858
This pull request updates the GetErrorsTool to 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.tsx to use extUriBiasedIgnorePathCase.isEqualOrParent and isEqual for 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.tsx to verify that diagnostics are correctly matched even when the drive letter casing differs (e.g., C: vs c:). These tests are conditionally run only on Windows.

These changes improve cross-platform reliability and correctness of diagnostic retrieval in the Copilot extension.

Copilot AI review requested due to automatic review settings June 5, 2026 06:19
Copy link
Copy Markdown
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

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 extUriBiasedIgnorePathCase to 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.

Comment on lines +145 to +158
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] }
]);
});
Comment on lines +56 to +58
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)) {
Comment on lines +104 to +107
const isExactMatch = extUriBiasedIgnorePathCase.isEqual(
resource,
path.uri,
);
@Wangmz-1211
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@Wangmz-1211 Wangmz-1211 marked this pull request as ready for review June 5, 2026 06:33
@roblourens
Copy link
Copy Markdown
Member

I disagree that we should always ignore the path casing

@Wangmz-1211
Copy link
Copy Markdown
Author

I disagree that we should always ignore the path casing

A new function normalizeDriveLetter was added to GetErrorsTool class and public for testing purposes only, which is same as getDiagnostics. Test suite was added to getErrorsTool.spec.tsx.

The new function works for Windows only, and change only the drive letter to lowercase. This avoids always ignoring path casing.

@Wangmz-1211 Wangmz-1211 force-pushed the fix/getErrors-tool-uri-parsing branch 2 times, most recently from 20b1d16 to c748769 Compare June 6, 2026 06:02
towa-wangmingzhuang and others added 3 commits June 6, 2026 23:01
…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.
@Wangmz-1211 Wangmz-1211 force-pushed the fix/getErrors-tool-uri-parsing branch from c748769 to cd65ddf Compare June 6, 2026 15:01
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.

Agent tool read/problems on Windows is sensitive to drive letter case. Not stable enough.

4 participants