Allow Exact Match For Filters - #1649
Conversation
|
@microsoft-github-policy-service agree |
|
Thanks, this is a reasonable addition and the trailing-separator approach is backward compatible. One blocker and two smaller asks before merge: Windows separator gap. The typical config form is if (/[\\/]$/.test(exclude)) {
exclude = exclude.slice(0, -1);
isDirect = true;
} else {
isDirect = this.isFilePath(exclude);
}Docs. The trailing-slash convention isn't discoverable — can you update Test. A small unit test covering the new exact-match path in |
|
Changyong Gong (@chagong) I finally got around to addressing the (very good!) feedback :) Can you re-take a peek? |
| let exclude = p.slice(1); | ||
| let isDirect: boolean; | ||
|
|
||
| if (/[\\/]$/.test(exclude)) { |
There was a problem hiding this comment.
before normalization, and using the exact code-block suggested, per feedback!
Changyong Gong (chagong)
left a comment
There was a problem hiding this comment.
The revised Windows separator handling and tests address the earlier feedback, but the trailing-separator comparison and documentation wording still need adjustment before merge.
| for (const [excludedPath, isFile] of excludes.entries()) { | ||
| if (isFile && r === excludedPath) { | ||
| for (const [excludedPath, isDirect] of excludes.entries()) { | ||
| if (isDirect && r === excludedPath) { |
There was a problem hiding this comment.
Could you normalize trailing separators consistently on both sides before this exact comparison? Currently, ["C:\\workspace\\lib\\", "!C:\\workspace\\lib\\"] leaves the separator on r but removes it from excludedPath, so the directory is not excluded. Please also add forward-slash and backslash tests where the included entry ends in a separator, taking care not to alter filesystem roots.
| "java.debugger.launch.modulePaths.runtime": "The module paths within 'runtime' scope of current project.", | ||
| "java.debugger.launch.modulePaths.test": "The module paths within 'test' scope of current project.", | ||
| "java.debugger.launch.modulePaths.exclude": "The path after '!' will be excluded from the modulePaths.", | ||
| "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.", |
There was a problem hiding this comment.
This should say “A trailing slash or backslash will treat the path as an exact match.” The current wording suggests that any slash triggers exact matching, while the implementation only checks the final character. Please make the same change to the classPaths.exclude description.
I was having cases where filters were matching inappropriately, for example with composite builds. This lets you have an exact match syntax. I know it's a bit niche, but I do think it's useful/I personally use it!