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

hitting shift enter before a } adds an indent #37136

Closed
lopugit opened this issue Oct 30, 2017 · 10 comments
Closed

hitting shift enter before a } adds an indent #37136

lopugit opened this issue Oct 30, 2017 · 10 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-folding Editor code folding issues verified Verification succeeded
Milestone

Comments

@lopugit
Copy link

lopugit commented Oct 30, 2017

  • VSCode Version: 1.17.2
  • OS Version: Linux Mint 18.x / OS X / WINDOWS

Steps to Reproduce:

  1. write two blocks of code
  2. fold the first one with the minus icon next to the line number
  3. put your cursor inside the first line of the 2nd block of code you wrote
  4. then hit shift enter
  5. see that your cursor will go into the first line of the folded block above

super annoying because it means you have to unfold every level of folded content before you can insert text between a line of text that is right below the folded content, because when you fold content it folds all blank lines below it too, meaning that when you shift enter to insert a block of code, it's impossible to do so without unfolding

If someone can point me in the direction of where this code might be stored I will try to rewrite it myself

Reproduces without extensions: Yes

GIF:
https://gyazo.com/27c8ba04bc93410d7eb2005abb5fd0bb

@vscodebot vscodebot bot added editor editor-folding Editor code folding issues labels Oct 30, 2017
@octref
Copy link
Contributor

octref commented Oct 31, 2017

Folding related so pass to @aeschli

@aeschli
Copy link
Contributor

aeschli commented Nov 1, 2017

Reproduced with this example:

function thisFoldsToEndOfPage() {
    const variable = [];
}

The problem is that pressing enter before } adds a new line and indentation.

function thisFoldsToEndOfPage() {
    const variable = [];

  }

So the folding region no longer ends with } and includes more lines. Its folding state is restored and the cursor is moved to a visible area.

Ideally this can be fixed in the auto indent strategy, to no add any indent before '}'

@aeschli aeschli assigned alexdima and unassigned aeschli Nov 1, 2017
@aeschli aeschli changed the title hitting shift enter when under a folded block of code will put the cursor just before the ... of the folded content line hitting shift enter before a } adds an indent Nov 1, 2017
@aeschli aeschli added editor-autoindent Editor auto indentation issues and removed editor-folding Editor code folding issues labels Nov 1, 2017
@alexdima
Copy link
Member

alexdima commented Nov 1, 2017

@aeschli Shouldn't an edit inside a folded region cause the region to become unfolded ?

This is an intersection of two features, so leaving both owners... i.e. folding is correct without autoindent, autoindent is correct without folding...

@alexdima alexdima assigned aeschli and unassigned alexdima Nov 1, 2017
@alexdima alexdima added the editor-folding Editor code folding issues label Nov 1, 2017
@lopugit
Copy link
Author

lopugit commented Nov 1, 2017

Ahhh it's an auto indent thing, hmmmmmmm, if I can help in any way.. Otherwise, have fun with this one aeschli :')

@aeschli
Copy link
Contributor

aeschli commented Nov 1, 2017

@alexandrudima It's not really inside the folded region, just outside.

@aeschli
Copy link
Contributor

aeschli commented Nov 1, 2017

Auto indent also is wrong without folding.

@aeschli aeschli removed the editor-folding Editor code folding issues label Nov 1, 2017
@aeschli aeschli removed their assignment Nov 1, 2017
@lopugit
Copy link
Author

lopugit commented Nov 1, 2017

@aeschli

this also happens with no } present if you're interested
https://gyazo.com/5319e2126769ba2abab9d07a1296c3a5

@aeschli
Copy link
Contributor

aeschli commented Nov 2, 2017

Yes, inside a block you want the indent. But before a closing bracket you want a reduced indent.

@rebornix rebornix added the bug Issue identified by VS Code Team member as probable bug label Nov 16, 2017
@rebornix
Copy link
Member

@aeschli there might be issues with auto indent but when auto indent is correct, the problem @lopugit described still existed

1.19-Insiders, TypeScript file.
indent-with-fold

In above gif, I tried to run Insert Line Above at the line of }, it inserts a new line above with good indentation (see what I did with the second block). Then I fold the first block, run the command again, it inserts a new line, the cursor goes to the first line. After unfolding, you can see that the }'s indentation doesn't change, so it doesn't affect how we fold.

@rebornix rebornix added under-discussion Issue is under discussion for relevance, priority, approach and removed bug Issue identified by VS Code Team member as probable bug editor-autoindent Editor auto indentation issues labels Nov 27, 2017
@aeschli aeschli added this to the November 2017 milestone Nov 30, 2017
@aeschli aeschli added editor-folding Editor code folding issues bug Issue identified by VS Code Team member as probable bug and removed under-discussion Issue is under discussion for relevance, priority, approach labels Nov 30, 2017
@aeschli
Copy link
Contributor

aeschli commented Nov 30, 2017

@rebornix Oh, now I see it, it's with Insert Line Above.
I pushed a fix.

@mjbvz mjbvz added the verified Verification succeeded label Dec 5, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 14, 2018
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 verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants