Skip to content

Commit 8d1a739

Browse files
committed
Watch variables in remote and prompt the user to restart the window
1 parent ecc3f57 commit 8d1a739

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

src/remote/remote.ts

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,6 @@ export class Remote {
501501
sshMonitor.onLogFilePathChange((newPath) => {
502502
this.commands.workspaceLogPath = newPath;
503503
}),
504-
// Watch for logDir configuration changes
505-
this.watchLogDirSetting(logDir, featureSet),
506504
// Register the label formatter again because SSH overrides it!
507505
vscode.extensions.onDidChange(() => {
508506
// Dispose previous label formatter
@@ -516,6 +514,19 @@ export class Remote {
516514
}),
517515
...(await this.createAgentMetadataStatusBar(agent, workspaceClient)),
518516
);
517+
518+
const settingsToWatch = [
519+
{ setting: "coder.sshConfig", title: "SSH configuration" },
520+
{ setting: "coder.globalFlags", title: "Global flags" },
521+
{ setting: "coder.sshFlags", title: "SSH flags" },
522+
];
523+
if (featureSet.proxyLogDirectory) {
524+
settingsToWatch.push({
525+
setting: "coder.proxyLogDirectory",
526+
title: "Proxy log directory",
527+
});
528+
}
529+
disposables.push(this.watchSettings(settingsToWatch));
519530
} catch (ex) {
520531
// Whatever error happens, make sure we clean up the disposables in case of failure
521532
disposables.forEach((d) => d.dispose());
@@ -790,29 +801,26 @@ export class Remote {
790801
return sshConfig.getRaw();
791802
}
792803

793-
private watchLogDirSetting(
794-
currentLogDir: string,
795-
featureSet: FeatureSet,
804+
private watchSettings(
805+
settings: Array<{ setting: string; title: string }>,
796806
): vscode.Disposable {
797807
return vscode.workspace.onDidChangeConfiguration((e) => {
798-
if (!e.affectsConfiguration("coder.proxyLogDirectory")) {
799-
return;
800-
}
801-
const newLogDir = this.getLogDir(featureSet);
802-
if (newLogDir === currentLogDir) {
803-
return;
808+
for (const { setting, title } of settings) {
809+
if (!e.affectsConfiguration(setting)) {
810+
continue;
811+
}
812+
vscode.window
813+
.showInformationMessage(
814+
`${title} setting changed. Reload window to apply.`,
815+
"Reload",
816+
)
817+
.then((action) => {
818+
if (action === "Reload") {
819+
vscode.commands.executeCommand("workbench.action.reloadWindow");
820+
}
821+
});
822+
break;
804823
}
805-
806-
vscode.window
807-
.showInformationMessage(
808-
"Log directory configuration changed. Reload window to apply.",
809-
"Reload",
810-
)
811-
.then((action) => {
812-
if (action === "Reload") {
813-
vscode.commands.executeCommand("workbench.action.reloadWindow");
814-
}
815-
});
816824
});
817825
}
818826

0 commit comments

Comments
 (0)