|
|
@ -78,9 +78,9 @@ export class UriTrie { |
|
|
|
this.trie.clear(); |
|
|
|
} |
|
|
|
|
|
|
|
delete(uri: Uri): boolean { |
|
|
|
delete(uri: Uri, dispose: boolean = true): boolean { |
|
|
|
const { path, ignoreCase } = this.normalize(uri); |
|
|
|
return this.trie.delete(path, ignoreCase); |
|
|
|
return this.trie.delete(path, ignoreCase, dispose); |
|
|
|
} |
|
|
|
|
|
|
|
get(uri: Uri): T | undefined { |
|
|
@ -390,7 +390,7 @@ export class PathTrie { |
|
|
|
this.root.children = undefined; |
|
|
|
} |
|
|
|
|
|
|
|
delete(path: string, ignoreCase?: boolean): boolean { |
|
|
|
delete(path: string, ignoreCase?: boolean, dispose: boolean = true): boolean { |
|
|
|
path = this.normalize(path); |
|
|
|
ignoreCase = ignoreCase ?? !isLinux; |
|
|
|
|
|
|
@ -407,7 +407,11 @@ export class PathTrie { |
|
|
|
|
|
|
|
if (!node?.value) return false; |
|
|
|
|
|
|
|
if (dispose) { |
|
|
|
disposeValue(node.value); |
|
|
|
} |
|
|
|
node.value = undefined; |
|
|
|
|
|
|
|
if ((node.children == null || node.children.size === 0) && parent?.children != null) { |
|
|
|
parent.children.delete(ignoreCase ? node.path.toLowerCase() : node.path); |
|
|
|
if (parent.children.size === 0) { |
|
|
@ -557,11 +561,20 @@ export class PathTrie { |
|
|
|
} |
|
|
|
|
|
|
|
const added = node.value == null; |
|
|
|
if (!added && node.value !== value) { |
|
|
|
disposeValue(node.value); |
|
|
|
} |
|
|
|
node.value = value; |
|
|
|
return added; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function disposeValue(obj: unknown): void { |
|
|
|
if (obj != null && typeof obj === 'object' && 'dispose' in obj && typeof obj.dispose === 'function') { |
|
|
|
obj.dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class VisitedPathNode { |
|
|
|
children: Map<string, VisitedPathNode> | undefined; |
|
|
|
|
|
|
|