A Regex file extension that makes it way easier to edit large regex.
using d flag for group indices
2 files changed, +10 -9
+8-8src/highlighter.ts
| @@ -48,7 +48,7 @@ class Highlighter { | ||
| 48 | 48 | options: vscode.DecorationRenderOptions = {} |
| 49 | 49 | ) { |
| 50 | 50 | const decoration = { range, hoverMessage: key }; |
| 51 | - output.log(`Highlighting ${key}`); | |
| 51 | + // output.log(`Highlighting ${key}`); | |
| 52 | 52 | const decorationType = decorationGenerator.generate(options); |
| 53 | 53 | if (this.highlightGroups[key]) { |
| 54 | 54 | this.highlightGroups[key].decorations.push(decoration); |
| @@ -91,19 +91,19 @@ class Highlighter { | ||
| 91 | 91 | this.updateOrCreateHighlightGroup("match", new vscode.Range(start, end), { |
| 92 | 92 | backgroundColor: "rgba(255, 255, 255, 0.1)", |
| 93 | 93 | }); |
| 94 | + | |
| 95 | + let groupIndex = 1; | |
| 94 | 96 | for (const groupName in match.groups) { |
| 95 | 97 | // 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); | |
| 103 | 102 | this.updateOrCreateHighlightGroup( |
| 104 | 103 | groupName, |
| 105 | 104 | new vscode.Range(start, end) |
| 106 | 105 | ); |
| 106 | + groupIndex++; | |
| 107 | 107 | } |
| 108 | 108 | i++; |
| 109 | 109 | } |
+2-1src/regexButtons.ts
| @@ -72,7 +72,8 @@ class RegexButtons { | ||
| 72 | 72 | .map(([key, _]) => key) |
| 73 | 73 | .join("") |
| 74 | 74 | .replace("x", "") |
| 75 | - .replace("y", ""); | |
| 75 | + .replace("y", "") | |
| 76 | + .concat("d"); | |
| 76 | 77 | } |
| 77 | 78 | |
| 78 | 79 | hasXFlag() { |