Fix path completions for typesVersions (#49154)

* Fix path completions for typesVersions

* Add more tests

* Fix case when * is a fragment of a path component

* Once a path pattern matches, only return completions from that pattern and higher priority ones

* Fix iteration order issue

* Aesthetics
This commit is contained in:
Andrew Branch
2022-05-19 14:33:46 -07:00
committed by GitHub
parent f6a171309e
commit 0921eac6dc
10 changed files with 339 additions and 27 deletions

View File

@@ -2299,7 +2299,7 @@ namespace ts {
return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined;
}
function isPatternMatch({ prefix, suffix }: Pattern, candidate: string) {
export function isPatternMatch({ prefix, suffix }: Pattern, candidate: string) {
return candidate.length >= prefix.length + suffix.length &&
startsWith(candidate, prefix) &&
endsWith(candidate, suffix);