@@ -25,23 +25,31 @@ function copyMain() {
25
25
startSelection = endSelection = editor . document . offsetAt ( editor . selection . anchor ) ;
26
26
// Get the position of the start of the reusable
27
27
// Do this by parsing each character from the cursor leftwards
28
- // until reaching "{"
29
- for ( let parseCharacter = "" ; parseCharacter != "{" ; startSelection -- ) {
28
+ // until reaching "{" (for variables/reusables), or quotes or
29
+ // a colon (:) for article feature flag versioning
30
+ for ( let parseCharacter = "" ; ! parseCharacter . match ( / { | ' | " | : / ) ; startSelection -- ) {
30
31
let startPosition = editor . document . positionAt ( startSelection ) ;
31
32
let stopPosition = editor . document . positionAt ( startSelection + 1 ) ;
32
33
let textRange = new vscode . Range ( startPosition , stopPosition ) ;
33
34
parseCharacter = editor . document . getText ( textRange ) ;
34
- // console.log('startSelection = ' + startSelection + '; parseCharacter = ' + parseCharacter);
35
+ // console.log('startSelection = ' + startSelection + '; parseCharacter = ' + parseCharacter);
36
+ // If it's an article feature flag versioning, move rightwards one or two.
37
+ if ( parseCharacter . match ( / ' | " / ) ) { startSelection ++ ; }
38
+ else if ( parseCharacter . match ( / : / ) ) { startSelection = startSelection + 2 ; }
35
39
moveLeftBy = endSelection - startSelection ;
36
40
// console.log('move left by = ' + moveLeftBy);
37
41
}
38
42
// Get the position of the end of the reusable by parsing forwards
39
- for ( let parseCharacter = "" ; parseCharacter != "}" ; endSelection ++ ) {
43
+ // until reaching " }" (for variables/reusables), or quotes or
44
+ // a line end for article feature flag versioning
45
+ for ( let parseCharacter = "" ; ! parseCharacter . match ( / } | ' | " | \n / ) ; endSelection ++ ) {
40
46
let startPosition = editor . document . positionAt ( endSelection ) ;
41
47
let stopPosition = editor . document . positionAt ( endSelection + 1 ) ;
42
48
let textRange = new vscode . Range ( startPosition , stopPosition ) ;
43
49
parseCharacter = editor . document . getText ( textRange ) ;
44
50
// console.log('endSelection = ' + endSelection + '; parseCharacter = ' + parseCharacter);
51
+ // If it's an article feature flag versioning, move leftwards one.
52
+ if ( parseCharacter . match ( / ' | " | \n / ) ) { endSelection -- ; }
45
53
moveRightBy = endSelection - startSelection ;
46
54
// console.log('move left by = ' + moveRightBy);
47
55
}
@@ -58,11 +66,11 @@ function copyMain() {
58
66
by : "character" ,
59
67
value : moveRightBy ,
60
68
select : true
61
- } )
69
+ } )
62
70
63
71
}
64
72
else {
65
- vscode . window . showInformationMessage ( "Open reusales extension: cursor is not within a reusable or variable " ) ;
73
+ vscode . window . showInformationMessage ( "Cursor is not within a reusable, variable, or feature flag. " ) ;
66
74
}
67
75
68
76
}
0 commit comments