tweak bold regexp (#141968)

pull/141971/head
Megan Rogge 2022-02-01 14:10:02 -06:00 committed by GitHub
parent a48c94c91f
commit 265cca240a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

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