From 067090e3be3e98470a1a965a2bcbe303ebfc772c Mon Sep 17 00:00:00 2001 From: Luke Slevinsky Date: Thu, 15 Aug 2019 11:06:24 -0700 Subject: [PATCH 1/2] make sure we don't run unsaved files and make sure filepicker works --- src/extension.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 20f6ae396..7be21a5d5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -546,9 +546,10 @@ const getFileFromFilePicker = () => { openLabel: "Run File" }; - return vscode.window.showOpenDialog(options).then(fileUri => { + return vscode.window.showOpenDialog(options).then(async (fileUri) => { if (fileUri && fileUri[0] && fileUri[0].fsPath.endsWith(".py")) { console.log(`Selected file: ${fileUri[0].fsPath}`); + currentTextDocument = await vscode.workspace.openTextDocument(fileUri[0]) return fileUri[0].fsPath; } }); From edfccf67bb832a236bb3053e4c25a1819c6d69eb Mon Sep 17 00:00:00 2001 From: Luke Slevinsky Date: Thu, 15 Aug 2019 12:16:32 -0700 Subject: [PATCH 2/2] Fix trying to run untitled file --- src/extension.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index 7be21a5d5..01ed828c0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -282,6 +282,11 @@ export async function activate(context: vscode.ExtensionContext) { // Save on run await currentTextDocument.save(); + if (!currentTextDocument.fileName.endsWith(".py")) { + logToOutputChannel(outChannel, CONSTANTS.ERROR.NO_FILE_TO_RUN, true); + return; + } + logToOutputChannel( outChannel, CONSTANTS.INFO.FILE_SELECTED(currentFileAbsPath)