@@ -16,15 +16,21 @@ export function getLanguageBoundaries(
16
16
if ( isVueDoc ( doc ) ) {
17
17
let text = doc . getText ( )
18
18
let blocks = findAll (
19
- / < (?< type > t e m p l a t e | s t y l e | s c r i p t ) \b [ ^ > ] * > .* ?( < \/ \k<type > > | $ ) / gis,
19
+ / (?< open > < (?< type > t e m p l a t e | s t y l e | s c r i p t ) \b [ ^ > ] * > ) .* ?(?< close > < \/ \k<type > > | $ ) / gis,
20
20
text
21
21
)
22
22
let htmlRanges : Range [ ] = [ ]
23
23
let cssRanges : Range [ ] = [ ]
24
24
for ( let i = 0 ; i < blocks . length ; i ++ ) {
25
25
let range = {
26
- start : indexToPosition ( text , blocks [ i ] . index ) ,
27
- end : indexToPosition ( text , blocks [ i ] . index + blocks [ i ] [ 0 ] . length ) ,
26
+ start : indexToPosition (
27
+ text ,
28
+ blocks [ i ] . index + blocks [ i ] . groups . open . length
29
+ ) ,
30
+ end : indexToPosition (
31
+ text ,
32
+ blocks [ i ] . index + blocks [ i ] [ 0 ] . length - blocks [ i ] . groups . close . length
33
+ ) ,
28
34
}
29
35
if ( blocks [ i ] . groups . type === 'style' ) {
30
36
cssRanges . push ( range )
@@ -41,7 +47,10 @@ export function getLanguageBoundaries(
41
47
42
48
if ( isHtmlDoc ( state , doc ) || isJsDoc ( state , doc ) || isSvelteDoc ( doc ) ) {
43
49
let text = doc . getText ( )
44
- let styleBlocks = findAll ( / < s t y l e (?: \s [ ^ > ] * > | > ) .* ?( < \/ s t y l e > | $ ) / gis, text )
50
+ let styleBlocks = findAll (
51
+ / (?< open > < s t y l e (?: \s [ ^ > ] * > | > ) ) .* ?(?< close > < \/ s t y l e > | $ ) / gis,
52
+ text
53
+ )
45
54
let htmlRanges : Range [ ] = [ ]
46
55
let cssRanges : Range [ ] = [ ]
47
56
let currentIndex = 0
@@ -52,10 +61,15 @@ export function getLanguageBoundaries(
52
61
end : indexToPosition ( text , styleBlocks [ i ] . index ) ,
53
62
} )
54
63
cssRanges . push ( {
55
- start : indexToPosition ( text , styleBlocks [ i ] . index ) ,
64
+ start : indexToPosition (
65
+ text ,
66
+ styleBlocks [ i ] . index + styleBlocks [ i ] . groups . open . length
67
+ ) ,
56
68
end : indexToPosition (
57
69
text ,
58
- styleBlocks [ i ] . index + styleBlocks [ i ] [ 0 ] . length
70
+ styleBlocks [ i ] . index +
71
+ styleBlocks [ i ] [ 0 ] . length -
72
+ styleBlocks [ i ] . groups . close . length
59
73
) ,
60
74
} )
61
75
currentIndex = styleBlocks [ i ] . index + styleBlocks [ i ] [ 0 ] . length
0 commit comments