fix(vscode): normalize status path comparison (#3322)
Closes #3308. Thanks for fixing the misleading Windows status diagnostic and adding the focused regression tests.
This commit is contained in:
@@ -4,6 +4,7 @@ import { AgentManagerPanelProvider } from './AgentManagerPanelProvider';
|
||||
import { SessionEditorPanelProvider } from './SessionEditorPanelProvider';
|
||||
import { createOpenCodeManager, type OpenCodeManager } from './opencode';
|
||||
import { startGlobalEventWatcher, stopGlobalEventWatcher, setChatViewProvider } from './sessionActivityWatcher';
|
||||
import { pathsEqualWithNormalizedDriveLetter } from './pathUtils';
|
||||
import { resolveWorkspaceFolders } from './workspaceResolver';
|
||||
|
||||
let chatViewProvider: ChatViewProvider | undefined;
|
||||
@@ -537,7 +538,9 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
const debug = openCodeManager?.getDebugInfo();
|
||||
const resolvedApiUrl = openCodeManager?.getApiUrl();
|
||||
const workingDirectory = openCodeManager?.getWorkingDirectory() ?? '';
|
||||
const workingDirectoryMatchesWorkspace = Boolean(primaryWorkspace && workingDirectory === primaryWorkspace);
|
||||
const workingDirectoryMatchesWorkspace = Boolean(
|
||||
primaryWorkspace && pathsEqualWithNormalizedDriveLetter(workingDirectory, primaryWorkspace)
|
||||
);
|
||||
let resolvedApiPath = '';
|
||||
if (resolvedApiUrl) {
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, test } from 'node:test';
|
||||
import { pathsEqualWithNormalizedDriveLetter } from './pathUtils';
|
||||
|
||||
describe('pathsEqualWithNormalizedDriveLetter', () => {
|
||||
test('matches Windows paths that differ only in drive-letter case', () => {
|
||||
assert.equal(
|
||||
pathsEqualWithNormalizedDriveLetter('C:\\Users\\user\\project', 'c:\\Users\\user\\project'),
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
test('does not ignore case outside the drive letter', () => {
|
||||
assert.equal(
|
||||
pathsEqualWithNormalizedDriveLetter('C:\\Users\\user\\project', 'C:\\Users\\User\\project'),
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
test('preserves exact comparison for paths without a Windows drive letter', () => {
|
||||
assert.equal(pathsEqualWithNormalizedDriveLetter('/work/project', '/work/project'), true);
|
||||
assert.equal(pathsEqualWithNormalizedDriveLetter('/work/project', '/work/other'), false);
|
||||
});
|
||||
});
|
||||
@@ -7,3 +7,6 @@
|
||||
*/
|
||||
export const normalizeWindowsDriveLetter = (p: string): string =>
|
||||
p.replace(/^([a-z]):/, (_, letter: string) => letter.toUpperCase() + ':');
|
||||
|
||||
export const pathsEqualWithNormalizedDriveLetter = (left: string, right: string): boolean =>
|
||||
normalizeWindowsDriveLetter(left) === normalizeWindowsDriveLetter(right);
|
||||
|
||||
Reference in New Issue
Block a user