irongit

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

using d flag for group indices

huncholanehuncholaneauthored
parent a2f840ccommit 7f3c6c1e93112b4cdd232857eb539ca27a6004dfBrowse files

2 files changed, +10 -9

+8-8src/highlighter.ts
@@ -48,7 +48,7 @@ class Highlighter {
4848 options: vscode.DecorationRenderOptions = {}
4949 ) {
5050 const decoration = { range, hoverMessage: key };
51- output.log(`Highlighting ${key}`);
51+ // output.log(`Highlighting ${key}`);
5252 const decorationType = decorationGenerator.generate(options);
5353 if (this.highlightGroups[key]) {
5454 this.highlightGroups[key].decorations.push(decoration);
@@ -91,19 +91,19 @@ class Highlighter {
9191 this.updateOrCreateHighlightGroup("match", new vscode.Range(start, end), {
9292 backgroundColor: "rgba(255, 255, 255, 0.1)",
9393 });
94+
95+ let groupIndex = 1;
9496 for (const groupName in match.groups) {
9597 // output.log(`Match: ${groupName}`);
96- const group = match.groups[groupName];
97- const start = document.positionAt(
98- match.index + match[0].indexOf(group)
99- );
100- const end = document.positionAt(
101- match.index + match[0].indexOf(group) + group.length
102- );
98+ const groupStartIndex = (match as any).indices[groupIndex][0];
99+ const groupEndIndex = (match as any).indices[groupIndex][1];
100+ const start = document.positionAt(groupStartIndex);
101+ const end = document.positionAt(groupEndIndex);
103102 this.updateOrCreateHighlightGroup(
104103 groupName,
105104 new vscode.Range(start, end)
106105 );
106+ groupIndex++;
107107 }
108108 i++;
109109 }
+2-1src/regexButtons.ts
@@ -72,7 +72,8 @@ class RegexButtons {
7272 .map(([key, _]) => key)
7373 .join("")
7474 .replace("x", "")
75- .replace("y", "");
75+ .replace("y", "")
76+ .concat("d");
7677 }
7778
7879 hasXFlag() {