Escape brackets in glob patterns (#694)

master
Brad Cornes 2023-01-05 14:56:39 +00:00 committed by GitHub
parent d0b4a3ecda
commit dd6bb57f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -2120,14 +2120,15 @@ class TW {
} }
return 0 return 0
}) })
for (let { pattern, priority } of documentSelector) { for (let selector of documentSelector) {
let fsPath = URI.parse(document.uri).fsPath let fsPath = URI.parse(document.uri).fsPath
let pattern = selector.pattern.replace(/[\[\]{}]/g, (m) => `\\${m}`)
if (pattern.startsWith('!') && minimatch(fsPath, pattern.slice(1), { dot: true })) { if (pattern.startsWith('!') && minimatch(fsPath, pattern.slice(1), { dot: true })) {
break break
} }
if (minimatch(fsPath, pattern, { dot: true }) && priority < matchedPriority) { if (minimatch(fsPath, pattern, { dot: true }) && selector.priority < matchedPriority) {
matchedProject = project matchedProject = project
matchedPriority = priority matchedPriority = selector.priority
} }
} }
} else { } else {