diff --git a/src/lsp/util/getLanguageBoundaries.ts b/src/lsp/util/getLanguageBoundaries.ts index c309aaeca3846b7f2f0fc98af7cf80a95e6cd817..dfef2300d3a9052cb3f60970538858b81d8af39b 100644 --- a/src/lsp/util/getLanguageBoundaries.ts +++ b/src/lsp/util/getLanguageBoundaries.ts @@ -16,21 +16,15 @@ ): LanguageBoundaries | null { if (isVueDoc(doc)) { let text = doc.getText() let blocks = findAll( - /(?<(?template|style|script)\b[^>]*>).*?(?<\/\k>|$)/gis, + /<(?template|style|script)\b[^>]*>.*?(<\/\k>|$)/gis, text ) let htmlRanges: Range[] = [] let cssRanges: Range[] = [] for (let i = 0; i < blocks.length; i++) { let range = { - start: indexToPosition( - text, - blocks[i].index + blocks[i].groups.open.length - ), - end: indexToPosition( - text, - blocks[i].index + blocks[i][0].length - blocks[i].groups.close.length - ), + start: indexToPosition(text, blocks[i].index), + end: indexToPosition(text, blocks[i].index + blocks[i][0].length), } if (blocks[i].groups.type === 'style') { cssRanges.push(range) @@ -47,10 +41,7 @@ } if (isHtmlDoc(state, doc) || isJsDoc(state, doc) || isSvelteDoc(doc)) { let text = doc.getText() - let styleBlocks = findAll( - /(?]*>|>)).*?(?<\/style>|$)/gis, - text - ) + let styleBlocks = findAll(/]*>|>).*?(<\/style>|$)/gis, text) let htmlRanges: Range[] = [] let cssRanges: Range[] = [] let currentIndex = 0 @@ -61,15 +52,10 @@ start: indexToPosition(text, currentIndex), end: indexToPosition(text, styleBlocks[i].index), }) cssRanges.push({ - start: indexToPosition( - text, - styleBlocks[i].index + styleBlocks[i].groups.open.length - ), + start: indexToPosition(text, styleBlocks[i].index), end: indexToPosition( text, - styleBlocks[i].index + - styleBlocks[i][0].length - - styleBlocks[i].groups.close.length + styleBlocks[i].index + styleBlocks[i][0].length ), }) currentIndex = styleBlocks[i].index + styleBlocks[i][0].length