mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 17:48:56 +01:00
use ternary search tree for uris instead of paths, fyi @bpasero, @sandy081, @roblourens, https://github.com/microsoft/vscode/issues/93368
This commit is contained in:
@@ -116,7 +116,7 @@ class ExtHostWorkspaceImpl extends Workspace {
|
||||
}
|
||||
|
||||
private readonly _workspaceFolders: vscode.WorkspaceFolder[] = [];
|
||||
private readonly _structure = TernarySearchTree.forPaths<vscode.WorkspaceFolder>();
|
||||
private readonly _structure = TernarySearchTree.forUris<vscode.WorkspaceFolder>();
|
||||
|
||||
constructor(id: string, private _name: string, folders: vscode.WorkspaceFolder[], configuration: URI | null, private _isUntitled: boolean) {
|
||||
super(id, folders.map(f => new WorkspaceFolder(f)), configuration);
|
||||
@@ -124,7 +124,7 @@ class ExtHostWorkspaceImpl extends Workspace {
|
||||
// setup the workspace folder data structure
|
||||
folders.forEach(folder => {
|
||||
this._workspaceFolders.push(folder);
|
||||
this._structure.set(folder.uri.toString(), folder);
|
||||
this._structure.set(folder.uri, folder);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,15 +141,15 @@ class ExtHostWorkspaceImpl extends Workspace {
|
||||
}
|
||||
|
||||
getWorkspaceFolder(uri: URI, resolveParent?: boolean): vscode.WorkspaceFolder | undefined {
|
||||
if (resolveParent && this._structure.get(uri.toString())) {
|
||||
if (resolveParent && this._structure.get(uri)) {
|
||||
// `uri` is a workspace folder so we check for its parent
|
||||
uri = dirname(uri);
|
||||
}
|
||||
return this._structure.findSubstr(uri.toString());
|
||||
return this._structure.findSubstr(uri);
|
||||
}
|
||||
|
||||
resolveWorkspaceFolder(uri: URI): vscode.WorkspaceFolder | undefined {
|
||||
return this._structure.get(uri.toString());
|
||||
return this._structure.get(uri);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user