Skip to content

Commit

Permalink
fixed to work only with markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi389111 committed Mar 30, 2023
1 parent 56fd77c commit 9a55d7c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@ export const activate = (context: vscode.ExtensionContext): void => {
};
createResources(true);

const REGEX_LINE = /^([ \t]*>)*[ \t]*\|[^\r\n]*$/mg;
const REGEX_COLUMN = /\|[^|\r\n]*(?=\|)/g;
/** onLanguage list defined in "activationEvents" of package.json */
const onLanguages = (context.extension.packageJSON["activationEvents"] as string[])
.filter(it => it.startsWith("onLanguage:"))
.map(it => it.substring("onLanguage:".length));
const updateDecorations = (editor: vscode.TextEditor): void => {
if (!onLanguages.includes(editor.document.languageId)) {
return;
}
const options: vscode.DecorationOptions[][] = decorationTypes.map(_ => []);
const REGEX_LINE = /^([ \t]*>)*[ \t]*\|[^\r\n]*$/mg;
Array.from(editor.document.getText().matchAll(REGEX_LINE)).forEach(matchLine => {
const REGEX_COLUMN = /\|[^|\r\n]*(?=\|)/g;
Array.from(matchLine[0].matchAll(REGEX_COLUMN)).forEach((matchColumn, index) => {
// `match.index` returned by `matchAll()` must exist.
// ref. https://github.com/microsoft/TypeScript/issues/36788
Expand Down

0 comments on commit 9a55d7c

Please sign in to comment.