Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuzzy matching folder names #242190

Merged
merged 1 commit into from
Feb 27, 2025
Merged

fuzzy matching folder names #242190

merged 1 commit into from
Feb 27, 2025

Conversation

benibenj
Copy link
Contributor

related microsoft/vscode-copilot#13497

@benibenj benibenj self-assigned this Feb 27, 2025
@benibenj benibenj enabled auto-merge (squash) February 27, 2025 14:41
@vs-code-engineering vs-code-engineering bot added this to the February 2025 milestone Feb 27, 2025
Comment on lines +493 to +519
function fuzzyMatchingGlobPattern(pattern: string): string {
if (!pattern) {
return '*';
}
return '*' + pattern.split('').join('*') + '*';
}

function continousMatchingGlobPattern(pattern: string): string {
if (!pattern) {
return '*';
}
return '*' + pattern + '*';
}

function caseInsensitiveGlobPattern(pattern: string): string {
let caseInsensitiveFilePattern = '';
for (let i = 0; i < pattern.length; i++) {
const char = pattern[i];
if (/[a-zA-Z]/.test(char)) {
caseInsensitiveFilePattern += `[${char.toLowerCase()}${char.toUpperCase()}]`;
} else {
caseInsensitiveFilePattern += char;
}
}
return caseInsensitiveFilePattern;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation: Introduce a Pattern class (which also defines how it matches and why it is ok to transform the pattern like that - which wouldn't work for regular expressions for example because of named groups that would be lowercased).

@benibenj benibenj merged commit d88e573 into main Feb 27, 2025
8 checks passed
@benibenj benibenj deleted the benibenj/various-kingfisher branch February 27, 2025 15:05
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.

2 participants