From 271a3121f59005060df0869472becf71617c620b Mon Sep 17 00:00:00 2001 From: Alena Khineika Date: Fri, 31 Mar 2023 00:22:59 +0200 Subject: [PATCH] fix: save documents from tree view and do not reopen them for playground runs VSCODE-399, VSCODE-400 (#504) * fix: save documents from tree view and do not reopen them for playground runs VSCODE-399, VSCODE-400 * refactor: save mongodb document when resource scheme is mongodb document scheme --- package.json | 4 ++-- src/editors/editorsController.ts | 6 +++--- src/editors/playgroundController.ts | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 5862115aa..4db2fbf65 100644 --- a/package.json +++ b/package.json @@ -619,7 +619,7 @@ }, { "command": "mdb.saveMongoDBDocument", - "when": "editorLangId == json" + "when": "resourceScheme == VIEW_DOCUMENT_SCHEME" }, { "command": "mdb.runSelectedPlaygroundBlocks", @@ -812,7 +812,7 @@ "command": "mdb.saveMongoDBDocument", "key": "ctrl+s", "mac": "cmd+s", - "when": "mdb.isPlayground == true" + "when": "resourceScheme == VIEW_DOCUMENT_SCHEME" } ], "capabilities": { diff --git a/src/editors/editorsController.ts b/src/editors/editorsController.ts index eb272b00f..971c01e4d 100644 --- a/src/editors/editorsController.ts +++ b/src/editors/editorsController.ts @@ -224,7 +224,6 @@ export default class EditorsController { DOCUMENT_SOURCE_URI_IDENTIFIER ) as DocumentSource; - // If not MongoDB document save to disk instead of MongoDB. if ( activeEditor.document.uri.scheme !== 'VIEW_DOCUMENT_SCHEME' || !namespace || @@ -233,8 +232,9 @@ export default class EditorsController { documentId === null || documentId === undefined ) { - await vscode.commands.executeCommand('workbench.action.files.save'); - + void vscode.window.showErrorMessage( + `The current file can not be saved as a MongoDB document. Invalid URL: ${activeEditor.document.uri.toString()}` + ); return false; } diff --git a/src/editors/playgroundController.ts b/src/editors/playgroundController.ts index 91ed1bb3c..1a6287bee 100644 --- a/src/editors/playgroundController.ts +++ b/src/editors/playgroundController.ts @@ -581,8 +581,6 @@ export default class PlaygroundController { this._playgroundResult = evaluateResponse.result; - this._explorerController.refresh(); - await this._openPlaygroundResult(); return true;