Skip to content
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

Avoid unfolding when typing ` #83353

Closed
akimikimikimikimikimikimika opened this issue Oct 26, 2019 · 7 comments
Closed

Avoid unfolding when typing ` #83353

akimikimikimikimikimikimika opened this issue Oct 26, 2019 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-folding Editor code folding issues help wanted Issues identified as good community contribution opportunities javascript JavaScript support issues
Milestone

Comments

@akimikimikimikimikimikimika

Issue Type: Feature Request

When I am editing my JavaScript source and use the character "`" for creating a string expression, I am always careful because JSLint regards whole the source after it as one string and unfolds all foldings after it. Of course, to prevent the problem, I need to type another "`" soon after the first one.
But if I forget it, this happens and I need to refold manually.
So I want JSLint to evaluate the source more slowly, especially deciding string or regex expressions.

VS Code version: Code 1.39.2 (6ab5985, 2019-10-15T15:33:00.827Z)
OS version: Darwin x64 19.0.0

@aeschli
Copy link
Contributor

aeschli commented Oct 28, 2019

Normally we autoclose the backtick (``) which avoids any dangling backticks that break the syntax tree.

@aeschli aeschli assigned mjbvz and unassigned aeschli Oct 28, 2019
@mjbvz mjbvz added editor-folding Editor code folding issues javascript JavaScript support issues labels Oct 28, 2019
@akimikimikimikimikimikimika
Copy link
Author

That's true. In most cases, autoclosing worked in my environment.
I found a case where I'm in trouble.
When I have a source like that:

let x=extremelyLongString;
 // enclosing like functions, objects, arrays are following

And to create:

let x=`extremelyLongString`;

In this case, if I select the text extremelyLongString and type `, closing will work correctly, but when the cursor is after the equal sign (=) and type `, all foldings in following source are unfolded.
This often happens when enclosing an extremely long string literary by mistake.

@aeschli
Copy link
Contributor

aeschli commented Oct 31, 2019

This is the same issue as #76990

@mjbvz Some ideas to try out (either in TypeScript or in our code):

  • if there's a syntax error due to an unclosed backtick do not report any folding regions (return undefined, not an empty []!). In that case folding will just continue with what it has.
  • if there's a syntax error due to an unclosed backtick, try an error recovery: iteratate over all multi-line backtick strings and close them on on the same line. Then reparse and see if this fixed the issue This might involve several passes to find the right backtick to close as the one that causes the issue might be closed by an other opening backtick later in the code.

@akimikimikimikimikimikimika
Copy link
Author

I cannot understand when autoclosing fired or not.
I opened several JS documents and HTML documents (with <script>) and tried.

  • In JS file, with just typing ` in any empty region, closing ` was inserted, but in HTML file, didn't work.
  • typing ` before variables will always unfold. (previous my comment)

Choosing "indentation" instead of "auto" in the setting "editor.foldingStrategy" might be better idea for me.

@cwewells
Copy link

I ran into this issue also. For me, unfolding happens with opening braces and brackets. I can avoid unfolding if I enclose portions of code in "#region" comments (i.e. for javascript), but overal not an elegant solution.

@thany
Copy link

thany commented Feb 6, 2020

Maybe VScode can somehow remember the contents of a line where code has been folded, and find those lines and restore fold state once the `` or /* */ block is closed? Might be tricky if a file contains lots of identical lines...

@mjbvz mjbvz added bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities labels Apr 15, 2020
@mjbvz mjbvz added this to the Backlog milestone Jul 7, 2020
@waitwhatActo
Copy link

I am having the same issue.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-folding Editor code folding issues help wanted Issues identified as good community contribution opportunities javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

6 participants