|
1 |
| -'use strict'; |
| 1 | +"use strict"; |
2 | 2 |
|
3 |
| -import { languages, commands, workspace, ExtensionContext, IndentAction, LanguageConfiguration, OnEnterRule, Disposable } from 'vscode'; |
4 |
| -import { Configuration } from './configuration'; |
| 3 | +import * as vscode from "vscode"; |
| 4 | + |
| 5 | +import {Configuration} from "./configuration"; |
5 | 6 |
|
6 |
| -let fs = require('fs'); |
7 | 7 | let configuration = new Configuration();
|
8 | 8 |
|
9 |
| -export function activate(context: ExtensionContext) { |
10 |
| - |
| 9 | +export function activate(context: vscode.ExtensionContext) { |
11 | 10 | configuration.configureCommentBlocks(context);
|
12 | 11 | configuration.registerCommands();
|
13 |
| -} |
14 | 12 |
|
15 |
| -export function deactivate() { |
16 |
| - |
| 13 | + const extensionNames = configuration.getExtensionNames(); |
| 14 | + |
| 15 | + const extensionName = extensionNames.name; |
| 16 | + const extensionDisplayName = extensionNames.displayName; |
| 17 | + |
| 18 | + let disabledLangConfig: string[] = configuration.getConfiguration().get("disabledLanguages"); |
| 19 | + |
| 20 | + if (disabledLangConfig.length > 0) { |
| 21 | + vscode.window.showInformationMessage(`${disabledLangConfig.join(", ")} languages are disabled for ${extensionDisplayName}.`); |
| 22 | + } |
| 23 | + |
| 24 | + /** |
| 25 | + * When the configuration/user settings are changed, set the extension |
| 26 | + * to reflect the settings and output a message to the user. |
| 27 | + */ |
| 28 | + vscode.workspace.onDidChangeConfiguration((event: any) => { |
| 29 | + /** |
| 30 | + * Blade Override Comments |
| 31 | + */ |
| 32 | + // If the affected setting is bladeOverrideComments... |
| 33 | + if (event.affectsConfiguration(`${extensionName}.bladeOverrideComments`)) { |
| 34 | + // Get the setting. |
| 35 | + let bladeOverrideComments: boolean = configuration.getConfiguration().get("bladeOverrideComments"); |
| 36 | + |
| 37 | + configuration.setBladeComments(bladeOverrideComments); |
| 38 | + |
| 39 | + if (!configuration.isLangIdDisabled("blade")) { |
| 40 | + vscode.window.showInformationMessage(`${bladeOverrideComments === false ? "Disabled" : "Enabled"} Blade Override Comments setting.`); |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Disabled Languages |
| 46 | + */ |
| 47 | + if (event.affectsConfiguration(`${extensionName}.disabledLanguages`)) { |
| 48 | + vscode.window |
| 49 | + .showInformationMessage( |
| 50 | + `The ${extensionName}.disabledLanguages setting has been changed. Please reload the Extension Host to take effect.`, |
| 51 | + "Reload" |
| 52 | + ) |
| 53 | + .then((selection) => { |
| 54 | + if (selection === "Reload") { |
| 55 | + vscode.commands.executeCommand("workbench.action.restartExtensionHost"); |
| 56 | + } |
| 57 | + }); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Override Default Language Block Comments |
| 62 | + */ |
| 63 | + if (event.affectsConfiguration(`${extensionName}.overrideDefaultLanguageMultiLineComments`)) { |
| 64 | + vscode.window |
| 65 | + .showInformationMessage( |
| 66 | + `The ${extensionName}.overrideDefaultLanguageMultiLineComments setting has been changed. Please reload the Extension Host to take effect.`, |
| 67 | + "Reload" |
| 68 | + ) |
| 69 | + .then((selection) => { |
| 70 | + if (selection === "Reload") { |
| 71 | + vscode.commands.executeCommand("workbench.action.restartExtensionHost"); |
| 72 | + } |
| 73 | + }); |
| 74 | + } |
| 75 | + }); |
| 76 | + |
| 77 | + // Called when active editor language is changed, so re-configure the comment blocks. |
| 78 | + vscode.workspace.onDidOpenTextDocument(() => { |
| 79 | + configuration.configureCommentBlocks(context); |
| 80 | + }); |
17 | 81 | }
|
| 82 | +export function deactivate() {} |
0 commit comments