irongit

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

hides buttons when regex file doesnt exist

huncholanehuncholaneauthored
parent 7f3c6c1commit 43173b63b37afc7ed564052090849a1d661e79a8Browse files

2 files changed, +33 -0

+2-0src/extension.ts
@@ -13,11 +13,13 @@ export function activate(context: vscode.ExtensionContext) {
1313 if (editor && editor.document.uri.scheme === "file") {
1414 if (editor.document.languageId === "regex") {
1515 // output.log("Regex file opened");
16+ regexButtons.show();
1617 highlighter.run();
1718 }
1819 }
1920 if (!editorsContainRegexFile()) {
2021 highlighter.reset();
22+ regexButtons.hide();
2123 output.log("No regex file opened");
2224 }
2325 });
+31-0src/regexButtons.ts
@@ -132,6 +132,37 @@ class RegexButtons {
132132
133133 disposeButtons() {
134134 // output.log("Disposing buttons");
135+ for (const flag of Object.values(this.flags)) {
136+ if (flag.button) {
137+ flag.button.dispose();
138+ }
139+ }
140+ }
141+
142+ hideButtons() {
143+ // output.log("Hiding buttons");
144+ for (const flag of Object.values(this.flags)) {
145+ if (flag.button) {
146+ flag.button.hide();
147+ }
148+ }
149+ }
150+
151+ hide() {
152+ this.hideButtons();
153+ }
154+
155+ showFlagButtons() {
156+ // output.log("Showing buttons");
157+ for (const flag of Object.values(this.flags)) {
158+ if (flag.button) {
159+ flag.button.show();
160+ }
161+ }
162+ }
163+
164+ show() {
165+ this.showFlagButtons();
135166 }
136167
137168 dispose() {