irongit

A Regex file extension that makes it way easier to edit large regex.

regex-file/src/extension.ts
51 lines1.4 KBJavaScript
1import * as vscode from "vscode";
2import { output } from "./output";
3import { editorsContainRegexFile } from "./utils";
4import { regexButtons } from "./regexButtons";
5import { highlighter } from "./highlighter";
6import decorationSelector from "./decorationSelector";
7
8export function activate(context: vscode.ExtensionContext) {
9 output.activate();
10 regexButtons.activate(context);
11 highlighter.activate(context);
12
13 if (editorsContainRegexFile()) {
14 highlighter.run();
15 regexButtons.show();
16 }
17
18 const activeEditorListener = vscode.window.onDidChangeActiveTextEditor(
19 (editor) => {
20 if (editor && editor.document.uri.scheme === "file") {
21 if (editorsContainRegexFile()) {
22 highlighter.run();
23 regexButtons.show();
24 } else {
25 highlighter.reset();
26 regexButtons.hide();
27 }
28 }
29 }
30 );
31
32 const textDocumentListener = vscode.workspace.onDidChangeTextDocument(
33 (event) => {
34 if (editorsContainRegexFile() && event.document.uri.scheme === "file") {
35 highlighter.run();
36 }
37 }
38 );
39
40 context.subscriptions.push(activeEditorListener, textDocumentListener);
41}
42
43export function deactivate() {
44 decorationSelector.dispose();
45 highlighter.dispose();
46 // console.log("Disposed highlighter");
47 regexButtons.dispose();
48 // console.log("Disposed regexButtons");
49 output.dispose();
50 // console.log("Disposed Output");
51}