|
15 | 15 |
|
16 | 16 | import * as vscode from "vscode"; |
17 | 17 | import * as path from "path"; |
| 18 | +import { tryAcquirePositronApi } from "@posit-dev/positron"; |
18 | 19 | import { MarkdownEngine } from "./markdown/engine"; |
19 | 20 | import { kQuartoDocSelector } from "./core/doc"; |
20 | 21 | import { activateLsp, deactivate as deactivateLsp } from "./lsp/client"; |
@@ -60,7 +61,7 @@ export async function activate(context: vscode.ExtensionContext) { |
60 | 61 | quartoPath, |
61 | 62 | workspaceFolder, |
62 | 63 | // Look for quarto in the app root; this is where Positron installs it |
63 | | - [path.join(vscode.env.appRoot, 'quarto', 'bin')], |
| 64 | + [path.join(vscode.env.appRoot, "quarto", "bin")], |
64 | 65 | vscode.window.showWarningMessage |
65 | 66 | ); |
66 | 67 | if (quartoContext.available) { |
@@ -129,9 +130,53 @@ export async function activate(context: vscode.ExtensionContext) { |
129 | 130 | // activate providers common to browser/node |
130 | 131 | activateCommon(context, host, engine, commands); |
131 | 132 |
|
| 133 | + // Register configuration change listener for Quarto path settings |
| 134 | + registerQuartoPathConfigListener(context, outputChannel); |
| 135 | + |
132 | 136 | outputChannel.info("Activated Quarto extension."); |
133 | 137 | } |
134 | 138 |
|
| 139 | +/** |
| 140 | + * Register a listener for changes to Quarto path settings that require a restart |
| 141 | + */ |
| 142 | +function registerQuartoPathConfigListener(context: vscode.ExtensionContext, outputChannel: vscode.LogOutputChannel) { |
| 143 | + // Check if we're in Positron |
| 144 | + const isPositron = tryAcquirePositronApi(); |
| 145 | + |
| 146 | + // List of settings that require restart when changed |
| 147 | + const quartoPathSettings = [ |
| 148 | + "quarto.path", |
| 149 | + "quarto.usePipQuarto", |
| 150 | + ]; |
| 151 | + const positronPathSettings = [ |
| 152 | + "quarto.useBundledQuartoInPositron" |
| 153 | + ]; |
| 154 | + |
| 155 | + // Listen for configuration changes |
| 156 | + context.subscriptions.push( |
| 157 | + vscode.workspace.onDidChangeConfiguration(event => { |
| 158 | + // Check if any of our path settings changed |
| 159 | + const requiresRestart = quartoPathSettings.some(setting => event.affectsConfiguration(setting)); |
| 160 | + const requiresPositronRestart = isPositron && positronPathSettings.some(setting => event.affectsConfiguration(setting)); |
| 161 | + |
| 162 | + if (requiresRestart || requiresPositronRestart) { |
| 163 | + outputChannel.info(`Quarto path settings changed, restart required: ${quartoPathSettings.filter(setting => |
| 164 | + event.affectsConfiguration(setting)).join(", ")}`); |
| 165 | + |
| 166 | + // Prompt user to restart |
| 167 | + vscode.window.showInformationMessage( |
| 168 | + "Quarto path settings have changed. Please reload the window for changes to take effect.", |
| 169 | + "Reload Window" |
| 170 | + ).then(selection => { |
| 171 | + if (selection === "Reload Window") { |
| 172 | + vscode.commands.executeCommand("workbench.action.reloadWindow"); |
| 173 | + } |
| 174 | + }); |
| 175 | + } |
| 176 | + }) |
| 177 | + ); |
| 178 | +} |
| 179 | + |
135 | 180 | export async function deactivate() { |
136 | 181 | return deactivateLsp(); |
137 | 182 | } |
0 commit comments