Skip to content

Commit ee5af88

Browse files
committed
Fix: ensure Windows drive letters are lowercased and improve path parsing
1 parent 482cbc3 commit ee5af88

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/commands/Folders.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,15 +636,23 @@ export class Folders {
636636
}
637637
}
638638

639+
// For Windows, we need to make sure the drive letter is lowercased for consistency
640+
if (isWindows()) {
641+
folders = folders.map((folder) => parseWinPath(folder));
642+
}
643+
639644
// Filter out the workspace folder
640645
if (wsFolder) {
641-
folders = folders.filter((folder) => folder !== wsFolder.fsPath);
646+
folders = folders.filter((folder) => folder !== parseWinPath(wsFolder.fsPath));
642647
}
643648

644649
const uniqueFolders = [...new Set(folders)];
650+
const relativeFolderPaths = uniqueFolders.map((folder) =>
651+
relative(parseWinPath(wsFolder.fsPath), folder)
652+
);
645653

646654
Logger.verbose('Folders:getContentFolders:end');
647-
return uniqueFolders.map((folder) => relative(wsFolder?.path || '', folder));
655+
return relativeFolderPaths;
648656
}
649657

650658
/**

src/helpers/parseWinPath.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
import { isWindows } from '../utils';
2+
13
export const parseWinPath = (path: string | undefined): string => {
2-
return path?.split(`\\`).join(`/`) || '';
4+
path = path?.split(`\\`).join(`/`) || '';
5+
6+
if (isWindows()) {
7+
// Check if path starts with a drive letter (e.g., "C:\")
8+
if (/^[a-zA-Z]:\\/.test(path)) {
9+
// Convert to lowercase drive letter
10+
path = path.charAt(0).toLowerCase() + path.slice(1);
11+
}
12+
}
13+
14+
return path;
315
};

0 commit comments

Comments
 (0)