Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/config-watcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as vscode from 'vscode';

const WATCHED_SETTINGS: String[] =
['path', 'arguments', 'trace', 'fallbackFlags', 'semanticHighlighting'];

async function handleConfigurationChanged(e: vscode.ConfigurationChangeEvent) {
for (let setting of WATCHED_SETTINGS) {
if (e.affectsConfiguration(`clangd.${setting}`)) {
vscode.commands.executeCommand('clangd.restart');
break;
}
}
}

export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.workspace.onDidChangeConfiguration(handleConfigurationChanged))
}
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from 'vscode';

import {ClangdContext} from './clangd-context';
import * as ConfigWatcher from './config-watcher';

/**
* This method is called when the extension is activated. The extension is
Expand All @@ -13,6 +14,9 @@ export async function activate(context: vscode.ExtensionContext) {
const clangdContext = new ClangdContext;
context.subscriptions.push(clangdContext);

// Listen for settings changes
ConfigWatcher.activate(context);

// An empty place holder for the activate command, otherwise we'll get an
// "command is not registered" error.
context.subscriptions.push(
Expand Down