mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-15 23:05:41 +00:00
improving code to work with multi-workspaces
This commit is contained in:
parent
1b8288ff96
commit
8e687f7afb
6 changed files with 89 additions and 23 deletions
|
@ -112,6 +112,24 @@ export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor {
|
|||
return isRustDocument(editor.document);
|
||||
}
|
||||
|
||||
export function isDocumentInWorkspace(document: RustDocument): boolean {
|
||||
const workspaceFolders = vscode.workspace.workspaceFolders;
|
||||
if (!workspaceFolders) {
|
||||
return false;
|
||||
}
|
||||
for (const folder of workspaceFolders) {
|
||||
if (document.uri.fsPath.startsWith(folder.uri.fsPath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function closeDocument(document: RustDocument) {
|
||||
await vscode.window.showTextDocument(document, { preview: true, preserveFocus: false });
|
||||
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
|
||||
}
|
||||
|
||||
export function isValidExecutable(path: string): boolean {
|
||||
log.debug("Checking availability of a binary at", path);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue