-
Notifications
You must be signed in to change notification settings - Fork 513
Code provider folding is not folding here strings #1417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ping @glennsarti |
Could it be something to do with me running 32-bit VSCode? That'd be odd but not unheard of. Are you looking at this file via the extension debug host? |
yes and I'm running 32bit too. |
What's the green squiggle saying underneath your |
That the variable |
So the test failure is on that particular piece of text. The plot thickens... AND I can repro that failure. |
Oh that's super weird. The tokenizer didn't see the heredoc. |
Yeah I wondered if it was a grammar problem... |
In that case, we should open an issue in EditorSyntax and mark as Resolution-External |
Nope...not so fast. I can repro the test failure, but not the actual failure. |
Currently thinking this is a test fixture issue and it's loading the wrong powershell grammar file... |
I noticed when the VSCode instance pops up during the test, it is v1.24.1. Even though I have v1.25 installed. |
@rkeithhill Can you please try changing the file from CRLF to LF to see if it makes a difference |
Hmm, that fixes it. So, uh, that's weird. |
It also fixes my test fixture problem. My git config is always use LF, which is why I may not have seen this. |
You may have Git configured to use LF but the repo configures itself to use |
@rkeithhill Ok so, it looks like I'm using the
This would mean the CRLF / LF problem would disappear. |
However....this throws out the order of the tokens which I depend on. I also tried regex-ing out the CRLF, but I can only replace them I can't strip them e.g. const content: string = document.getText().replace(/\r/g, " ");
const tokens: ITokenList = this.powershellGrammar.tokenizeLine(content, null).tokens; I can't remove them because later on I need to access the document text via character offset, which is then wrong because the tokenization comes from a "different" document content. I've narrowed it down to the regex used to determine the start of the heredoc The
So it may simply be a case of changing how it determines the end of the line. 🤷♂️ |
Previously the test fixtures were failing on some Windows systems due to git changing the line endings. This commit adds a new test fixture, and runs the same tests on the same content document, but each with a different line-ending (CRLF and LF).
Started a WIP PR, with tests and janky workaround. |
Previously the folding provider would tokenize the entire document at a time. While this mostly works, it causes issues with regular expressions which use the `$` anchor. This anchor will interpret CRLF vs LF differently. While it may be possible to munge the document prior to tokenization, the prior art within the VS Code codebase shows that this is not the intended usage, i.e. lines should be tokenized, not an entire document. This commit changes the tokenization process to tokenize per line but still preserves the original folding behaviour.
Previously the test fixtures were failing on some Windows systems due to git changing the line endings. This commit adds a new test fixture, and runs the same tests on the same content document, but each with a different line-ending (CRLF and LF).
Previously only single quoted here strings were tested for folding. This commit adds a test for the double quoted herestrings as well.
* (GH-1417) Tokenize a document per line to avoid line endings Previously the folding provider would tokenize the entire document at a time. While this mostly works, it causes issues with regular expressions which use the `$` anchor. This anchor will interpret CRLF vs LF differently. While it may be possible to munge the document prior to tokenization, the prior art within the VS Code codebase shows that this is not the intended usage, i.e. lines should be tokenized, not an entire document. This commit changes the tokenization process to tokenize per line but still preserves the original folding behaviour. * (GH-1417) Add tests for CRLF documents Previously the test fixtures were failing on some Windows systems due to git changing the line endings. This commit adds a new test fixture, and runs the same tests on the same content document, but each with a different line-ending (CRLF and LF). * (maint) Update folding test fixtures Previously some of the text in the test fixtures was confusing e.g. Text that says 'cannot fold' should read 'should fold'. This commit updates the text in the fixture to describe the expected behaviour for humans. * (GH-1417) Add folding tests for double quote here strings Previously only single quoted here strings were tested for folding. This commit adds a test for the double quoted herestrings as well. * (maint) Refactor folding test fixtures Previously there was some duplication in the folder test fixtures. This commit refactors the expectation to be more DRY. This commit also adds an expectation on the line endings as we're depending on git to clone correctly. Without this we may get false positive results.
System Details
$PSVersionTable
:Issue Description
Code folding via the folding provider seems to be working for everything except here strings:
FWIW the npm tests fail on my dev machine:
Attached Logs
The text was updated successfully, but these errors were encountered: