irongit

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

searches the correct files

huncholanehuncholaneauthored
parent a45a41acommit 9ea3c048273f763d4071500ca71049af2c6a522dBrowse files

4 files changed, +14 -12

+2-2src/extension.ts
@@ -12,7 +12,7 @@ export function activate(context: vscode.ExtensionContext) {
1212 vscode.window.onDidChangeActiveTextEditor((editor) => {
1313 if (editor && editor.document.uri.scheme === "file") {
1414 if (editor.document.languageId === "regex") {
15- output.log("Regex file opened");
15+ // output.log("Regex file opened");
1616 highlighter.run();
1717 }
1818 }
@@ -29,6 +29,6 @@ export function activate(context: vscode.ExtensionContext) {
2929 }
3030
3131 export function deactivate() {
32- output.log("Stopping File Regex extension");
32+ // output.log("Stopping File Regex extension");
3333 output.deactivate();
3434 }
+6-4src/highlighter.ts
@@ -17,17 +17,18 @@ class Highlighter {
1717 constructor() {}
1818
1919 activate(context: vscode.ExtensionContext) {
20- output.log("Highlighter activated");
20+ // output.log("Highlighter activated");
2121 this.context = context;
2222 }
2323
2424 reset() {
25- output.log("Resetting decorations");
25+ // output.log("Resetting decorations");
2626 this.decorations.forEach((decoration) => {
2727 decoration.dispose();
2828 });
2929 this.decorations = [];
3030 decorationGenerator.reset();
31+ output.clear();
3132 }
3233
3334 getHighlightGroups(
@@ -46,7 +47,7 @@ class Highlighter {
4647 const maxMatches = getConfig().get("maxMatches") as number;
4748 for (const match of matches) {
4849 if (i >= maxMatches) {
49- break;
50+ continue;
5051 }
5152 const start = document.positionAt(match.index);
5253 const end = document.positionAt(match.index + match[0].length);
@@ -56,11 +57,12 @@ class Highlighter {
5657 });
5758 i++;
5859 }
60+ output.log(`Found ${i} matches`);
5961 return highlightGroups;
6062 }
6163
6264 highlightMatches(regexEditor: vscode.TextEditor, editor: vscode.TextEditor) {
63- output.log(`Highlighting matches in ${editor.document.fileName}`);
65+ // output.log(`Highlighting matches in ${editor.document.fileName}`);
6466 const regex = regexEditor.document.getText();
6567 const flags = regexButtons.getFlagString();
6668 const highlightGroups = this.getHighlightGroups(
+4-4src/regexButtons.ts
@@ -79,7 +79,7 @@ class RegexButtons {
7979 }
8080
8181 toggleFlag(flag: Flag) {
82- output.log(`Toggling flag ${flag.char}`);
82+ // output.log(`Toggling flag ${flag.char}`);
8383 flag.state = flag.state === "on" ? "off" : "on";
8484 this.decorateFlag(flag);
8585 }
@@ -93,7 +93,7 @@ class RegexButtons {
9393 }
9494
9595 createButton(flag: Flag) {
96- output.log(`Creating button for ${flag}`);
96+ // output.log(`Creating button for ${flag}`);
9797 flag.button = vscode.window.createStatusBarItem(
9898 vscode.StatusBarAlignment.Left
9999 );
@@ -111,14 +111,14 @@ class RegexButtons {
111111 }
112112
113113 createButtons() {
114- output.log("Creating buttons");
114+ // output.log("Creating buttons");
115115 for (const flag of FLAG_CHARS) {
116116 this.createButton(flag);
117117 }
118118 }
119119
120120 disposeButtons() {
121- output.log("Disposing buttons");
121+ // output.log("Disposing buttons");
122122 }
123123
124124 dispose() {
+2-2src/utils.ts
@@ -22,7 +22,7 @@ export function getNonRegexEditors() {
2222 const editors = vscode.window.visibleTextEditors;
2323 return editors.filter(
2424 (editor) =>
25- editor.document.languageId !== "regex" ||
26- editor.document.uri.scheme !== "file"
25+ editor.document.languageId !== "regex" &&
26+ editor.document.uri.scheme === "file"
2727 );
2828 }