File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -193,8 +193,21 @@ export class FoldingProvider implements vscode.FoldingRangeProvider {
193
193
// If the grammar hasn't been setup correctly, return empty result
194
194
if ( this . powershellGrammar == null ) { return [ ] ; }
195
195
196
- // Convert the document text into a series of grammar tokens
197
- const tokens : ITokenList = this . powershellGrammar . tokenizeLine ( document . getText ( ) , null ) . tokens ;
196
+ // Note that the tokenizeLine only considers LF as a line ending therefore the document
197
+ // content needs to be stripped. As VSCode only supports CRLF and LF line endings this
198
+ // is safe to do.
199
+ const content : string = document . getText ( ) . replace ( / \r / g, " " ) ;
200
+ const tokens : ITokenList = this . powershellGrammar . tokenizeLine ( content , null ) . tokens ;
201
+
202
+ // const tokens2: ITokenList = this.powershellGrammar.tokenizeLine(document.getText(), null).tokens;
203
+
204
+ // for (let i = 0; i < tokens.length; i++) {
205
+ // if (tokens[i].startIndex !== tokens2[i].startIndex) { console.log("startindex different at " + i.toString()) }
206
+ // if (tokens[i].endIndex !== tokens2[i].endIndex) { console.log("endIndex different at " + i.toString()) }
207
+ // if (tokens[i].scopes.toString() !== tokens2[i].scopes.toString()) { console.log("scopes different at " + i.toString()) }
208
+ // }
209
+
210
+ // console.log("");
198
211
199
212
// Parse the token list looking for matching tokens and return
200
213
// a list of LineNumberRange objects. Then filter the list and only return matches
You can’t perform that action at this time.
0 commit comments