vscode#ConfigurationChangeEvent TypeScript Examples
The following examples show how to use
vscode#ConfigurationChangeEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From everforest-vscode with MIT License | 7 votes |
detectConfigChanges(
// {{{
event: ConfigurationChangeEvent,
onConfigChange: () => void
): void {
if (event.affectsConfiguration("everforest")) {
onConfigChange();
}
}
Example #2
Source File: extension.ts From plugin-vscode with Apache License 2.0 | 6 votes |
registerPreInitHandlers(): any {
// We need to restart VSCode if we change plugin configurations.
workspace.onDidChangeConfiguration((params: ConfigurationChangeEvent) => {
if (params.affectsConfiguration(BALLERINA_HOME) ||
params.affectsConfiguration(OVERRIDE_BALLERINA_HOME)) {
this.showMsgAndRestart(CONFIG_CHANGED);
}
});
languages.setLanguageConfiguration('ballerina', {
onEnterRules: [
{
beforeText: new RegExp('^\\s*#'),
action: {
appendText: '# ',
indentAction: IndentAction.None,
}
}
]
});
}
Example #3
Source File: leanclient.ts From vscode-lean4 with Apache License 2.0 | 5 votes |
configChanged(e : ConfigurationChangeEvent): void {
let newToolchainPath = this.storageManager.getLeanPath();
if (!newToolchainPath) newToolchainPath = toolchainPath();
if (this.toolchainPath !== newToolchainPath){
void this.restart();
}
}
Example #4
Source File: config-change-manager.ts From karma-test-explorer with MIT License | 5 votes |
private processConfigChangeSubscription(
configChangeEvent: ConfigurationChangeEvent,
configChangeSubscription: ConfigChangeSubscription<T>
): void {
const changedSettings: T[] = configChangeSubscription.watchedSettings.filter(configSetting =>
configChangeEvent.affectsConfiguration(
`${this.configPrefix}${configSetting}`,
configChangeSubscription.workspaceFolder
)
);
if (changedSettings.length === 0) {
return;
}
this.logger.debug(() => `Config Settings Changed: ${JSON.stringify(changedSettings, null, 2)}`);
if (configChangeSubscription.changeNotificationOptions?.showPrompt === false) {
configChangeSubscription.changeHandler(changedSettings);
return;
}
const unprocessedConfigChanges = this.unprocessedConfigChanges.get(configChangeSubscription);
if (!unprocessedConfigChanges) {
this.unprocessedConfigChanges.set(configChangeSubscription, new Set(changedSettings));
const promptMessage =
configChangeSubscription.changeNotificationOptions?.promptMessage || 'Settings changed. Apply the changes?';
window.showWarningMessage(promptMessage, ...Object.values(ConfigChangeAction)).then(selectedAction => {
if (selectedAction === ConfigChangeAction.ApplySettings) {
this.triggerConfigChangeSubscription(configChangeSubscription);
}
});
} else {
this.logger.debug(() => 'Ignoring new configuration changes - Confirmation already pending for previous changes');
changedSettings.forEach(changedSetting => unprocessedConfigChanges.add(changedSetting));
}
}
Example #5
Source File: config-change-manager.ts From karma-test-explorer with MIT License | 5 votes |
private handleConfigurationChange(configChangeEvent: ConfigurationChangeEvent): void {
this.logger.info(() => 'Configuration changed');
this.configChangeSubscriptions.forEach(configChangeSubscription =>
this.processConfigChangeSubscription(configChangeEvent, configChangeSubscription)
);
}
Example #6
Source File: extension.ts From vscode-todo-md with MIT License | 5 votes |
export async function activate(extensionContext: ExtensionContext) {
$state.extensionContext = extensionContext;
const lastVisitByFile = extensionContext.globalState.get<typeof $state['lastVisitByFile'] | undefined>(Constants.LastVisitByFileStorageKey);
$state.lastVisitByFile = lastVisitByFile ? lastVisitByFile : {};
$state.editorLineHeight = getEditorLineHeight();
updateEditorDecorationStyle();
updateUserSuggestItems();
registerAllCommands();
createAllTreeViews();
const defaultFileDocument = await getDocumentForDefaultFile();
if (defaultFileDocument) {
const filePath = defaultFileDocument.uri.toString();
const needReset = checkIfNeedResetRecurringTasks(filePath);
if (needReset) {
await resetAllRecurringTasks(defaultFileDocument, needReset.lastVisit);
await updateLastVisitGlobalState(filePath, new Date());
}
}
setTimeout(() => {
onChangeActiveTextEditor(window.activeTextEditor);// Trigger on change event at activation
});
await updateState();
Global.webviewProvider = new TasksWebviewViewProvider($state.extensionContext.extensionUri);
$state.extensionContext.subscriptions.push(
window.registerWebviewViewProvider(TasksWebviewViewProvider.viewType, Global.webviewProvider),
);
updateAllTreeViews();
updateArchivedTasks();
updateIsDevContext();
updateLanguageFeatures();
/**
* The event is fired twice quickly when closing an editor, also when swtitching to untitled file ???
*/
Global.changeActiveTextEditorDisposable = window.onDidChangeActiveTextEditor(throttle(onChangeActiveTextEditor, 20, {
leading: false,
}));
function onConfigChange(e: ConfigurationChangeEvent) {
if (!e.affectsConfiguration(Constants.ExtensionSettingsPrefix)) {
return;
}
updateConfig();
}
function updateConfig() {
$config = workspace.getConfiguration().get(Constants.ExtensionSettingsPrefix) as ExtensionConfig;
disposeEditorDisposables();
updateLanguageFeatures();
$state.editorLineHeight = getEditorLineHeight();
updateEditorDecorationStyle();
updateUserSuggestItems();
mainStatusBar.show();
onChangeActiveTextEditor(window.activeTextEditor);
updateIsDevContext();
}
function updateIsDevContext() {
if (process.env.NODE_ENV === 'development' || $config.isDev) {
setContext(VscodeContext.IsDev, true);
}
}
extensionContext.subscriptions.push(workspace.onDidChangeConfiguration(onConfigChange));
}