@@ -48,8 +48,9 @@ class Snippet {
48
48
let fields : { seq : number | null , name : string } [ ] = [ ]
49
49
let lines = [ ] , positions : FieldPos [ ] = [ ] , m
50
50
for ( let line of template . split ( / \r \n ? | \n / ) ) {
51
- while ( m = / [ # $ ] \{ (?: ( \d + ) (?: : ( [ ^ } ] * ) ) ? | ( [ ^ } ] * ) ) \} / . exec ( line ) ) {
52
- let seq = m [ 1 ] ? + m [ 1 ] : null , name = m [ 2 ] || m [ 3 ] || "" , found = - 1
51
+ while ( m = / [ # $ ] \{ (?: ( \d + ) (?: : ( [ ^ } ] * ) ) ? | ( (?: \\ [ { } ] | [ ^ } ] ) * ) ) \} / . exec ( line ) ) {
52
+ let seq = m [ 1 ] ? + m [ 1 ] : null , rawName = m [ 2 ] || m [ 3 ] || "" , found = - 1
53
+ let name = rawName . replace ( / \\ [ { } ] / g, m => m [ 1 ] )
53
54
for ( let i = 0 ; i < fields . length ; i ++ ) {
54
55
if ( seq != null ? fields [ i ] . seq == seq : name ? fields [ i ] . name == name : false ) found = i
55
56
}
@@ -61,7 +62,7 @@ class Snippet {
61
62
for ( let pos of positions ) if ( pos . field >= found ) pos . field ++
62
63
}
63
64
positions . push ( new FieldPos ( found , lines . length , m . index , m . index + name . length ) )
64
- line = line . slice ( 0 , m . index ) + name + line . slice ( m . index + m [ 0 ] . length )
65
+ line = line . slice ( 0 , m . index ) + rawName + line . slice ( m . index + m [ 0 ] . length )
65
66
}
66
67
line = line . replace ( / \\ ( [ { } ] ) / g, ( _ , brace , index ) => {
67
68
for ( let pos of positions ) if ( pos . line == lines . length && pos . from > index ) {
0 commit comments