Skip to content

Commit 49e4b45

Browse files
chore: feedback
1 parent 838d2cd commit 49e4b45

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

package.nls.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"java.debugger.launch.modulePaths.auto": "Automatically resolve the module paths of current project.",
99
"java.debugger.launch.modulePaths.runtime": "The module paths within 'runtime' scope of current project.",
1010
"java.debugger.launch.modulePaths.test": "The module paths within 'test' scope of current project.",
11-
"java.debugger.launch.modulePaths.exclude": "The path after '!' will be excluded from the modulePaths. A slash (forwards or backwards) will treat the path as an exact match.",
11+
"java.debugger.launch.modulePaths.exclude": "The path after '!' will be excluded from the modulePaths. A trailing slash or backslash will treat the path as an exact match.",
1212
"java.debugger.launch.classPaths.description": "The classpaths for launching the JVM. If not specified, the debugger will automatically resolve from current project.",
1313
"java.debugger.launch.classPaths.auto": "Automatically resolve the classpaths of current project.",
1414
"java.debugger.launch.classPaths.runtime": "The classpaths within 'runtime' scope of current project.",
1515
"java.debugger.launch.classPaths.test": "The classpaths within 'test' scope of current project.",
16-
"java.debugger.launch.classPaths.exclude": "The path after '!' will be excluded from the classpaths. A slash (forwards or backwards) will treat the path as an exact match.",
16+
"java.debugger.launch.classPaths.exclude": "The path after '!' will be excluded from the classpaths. A trailing slash or backslash will treat the path as an exact match.",
1717
"java.debugger.launch.sourcePaths.description": "The extra source directories of the program. The debugger looks for source code from project settings by default. This option allows the debugger to look for source code in extra directories.",
1818
"java.debugger.launch.encoding.description": "The file.encoding setting for the JVM. Possible values can be found in https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html.",
1919
"java.debugger.launch.cwd.description": "The working directory of the program. Defaults to the current workspace root.",

src/configurationProvider.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
514514

515515
return result.filter((r) => {
516516
for (const [excludedPath, isDirect] of excludes.entries()) {
517-
if (isDirect && r === excludedPath) {
517+
if (isDirect && stripTrailingSeparators(r) === stripTrailingSeparators(excludedPath)) {
518518
return false;
519519
}
520520

@@ -834,6 +834,22 @@ async function updateDebugSettings(event?: vscode.ConfigurationChangeEvent) {
834834
}
835835
}
836836

837+
/**
838+
* Removes trailing path separators for comparison, leaving filesystem roots
839+
* such as "/", "\\", or "C:\\" unchanged (including Windows drive roots when
840+
* running on POSIX).
841+
*/
842+
function stripTrailingSeparators(fsPath: string): string {
843+
if (!fsPath || fsPath === "/" || fsPath === "\\" || fsPath === path.parse(fsPath).root) {
844+
return fsPath;
845+
}
846+
// Windows drive root, recognized even when the host platform is POSIX.
847+
if (/^[A-Za-z]:[\\/]$/.test(fsPath)) {
848+
return fsPath;
849+
}
850+
return fsPath.replace(/[\\/]+$/, "");
851+
}
852+
837853
function needsBuildWorkspace(): boolean {
838854
const javaConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("java");
839855
return javaConfig?.debug?.settings?.forceBuildBeforeLaunch;

test/configurationProvider.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ suite("JavaDebugConfigurationProvider", () => {
6565
async function assertExactDirectoryExclusion(
6666
excludeSuffix: "\\" | "/",
6767
label: string,
68+
includeSuffix: "" | "\\" | "/" = "",
6869
): Promise<void> {
6970
const workspace = createTestWorkspace();
7071
workspaces.push(workspace);
@@ -73,7 +74,7 @@ suite("JavaDebugConfigurationProvider", () => {
7374
const jarFs = vscode.Uri.file(workspace.jarPath).fsPath;
7475
const filterExcluded = getFilterExcluded(new JavaDebugConfigurationProvider());
7576
const result = await filterExcluded(workspace.folder, [
76-
libDirFs,
77+
`${libDirFs}${includeSuffix}`,
7778
jarFs,
7879
`!${workspace.libDir}${excludeSuffix}`,
7980
]);
@@ -92,5 +93,13 @@ suite("JavaDebugConfigurationProvider", () => {
9293
test("treats a trailing forward slash as an exact match (Linux-style paths)", async () => {
9394
await assertExactDirectoryExclusion("/", "Linux-style");
9495
});
96+
97+
test("exact-matches when the included Windows-style path ends with a backslash", async () => {
98+
await assertExactDirectoryExclusion("\\", "Windows-style included trailing separator", "\\");
99+
});
100+
101+
test("exact-matches when the included Linux-style path ends with a forward slash", async () => {
102+
await assertExactDirectoryExclusion("/", "Linux-style included trailing separator", "/");
103+
});
95104
});
96105
});

0 commit comments

Comments
 (0)