tweak bold regexp (#141968)

This commit is contained in:
Megan Rogge
2022-02-01 14:10:02 -06:00
committed by GitHub
parent a48c94c91f
commit 265cca240a

View File

@@ -164,7 +164,7 @@ function createFencedRange(token: MarkdownItTokenWithMap, cursorLine: number, do
}
function createBoldRange(lineText: string, cursorChar: number, cursorLine: number, parent?: vscode.SelectionRange): vscode.SelectionRange | undefined {
const regex = /(?:\*\*([^*]+)(?:\*([^*]+)([^*]+)\*)*([^*]+)\*\*)/g;
const regex = /\*\*([^*]+\*?[^*]+\*?[^*]+)\*\*/gim;
const matches = [...lineText.matchAll(regex)].filter(match => lineText.indexOf(match[0]) <= cursorChar && lineText.indexOf(match[0]) + match[0].length >= cursorChar);
if (matches.length) {
// should only be one match, so select first and index 0 contains the entire match