Skip to content

Commit 8e23f89

Browse files
committed
(wip) todo
1 parent 746b2e9 commit 8e23f89

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/features/Folding.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,21 @@ export class FoldingProvider implements vscode.FoldingRangeProvider {
193193
// If the grammar hasn't been setup correctly, return empty result
194194
if (this.powershellGrammar == null) { return []; }
195195

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("");
198211

199212
// Parse the token list looking for matching tokens and return
200213
// a list of LineNumberRange objects. Then filter the list and only return matches

0 commit comments

Comments
 (0)