diff --git a/src/run.ts b/src/run.ts index 2b2c82a..a3be719 100644 --- a/src/run.ts +++ b/src/run.ts @@ -26,6 +26,8 @@ export async function pyRunApp(): Promise { return; } + await saveActiveEditorFile(); + const python = await getSelectedPythonInterpreter(); if (!python) { return; @@ -103,6 +105,8 @@ export async function pyDebugApp(): Promise { return; } + await saveActiveEditorFile(); + const python = await getSelectedPythonInterpreter(); if (!python) { return; @@ -137,6 +141,8 @@ export async function rRunApp(): Promise { return; } + await saveActiveEditorFile(); + const path = isShinyAppRPart(pathFile) ? path_dirname(pathFile) : pathFile; const port = await getAppPort("run", "r"); @@ -332,6 +338,12 @@ function getActiveEditorFile(): string | undefined { return appPath; } +async function saveActiveEditorFile(): Promise { + if (vscode.window.activeTextEditor?.document.isDirty) { + await vscode.window.activeTextEditor?.document.save(); + } +} + function getExtensionPath(): string | undefined { const extensionPath = vscode.extensions.getExtension("Posit.shiny")?.extensionPath;