Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/util.ts')
-rw-r--r--editors/code/src/util.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index 922fbcbcf3..0196b37b8b 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -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);