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

Annoying indent on opening braces if various statements #30691

Closed
simonl65 opened this issue Jul 14, 2017 · 13 comments
Closed

Annoying indent on opening braces if various statements #30691

simonl65 opened this issue Jul 14, 2017 · 13 comments
Assignees
Labels
editor-autoindent Editor auto indentation issues

Comments

@simonl65
Copy link

simonl65 commented Jul 14, 2017

  • VSCode Version: Code 1.14.0 (b8cd5b9, 2017-07-10T18:36:31.751Z)
  • OS Version: Windows_NT ia32 10.0.15063
  • Extensions:
Extension Author (truncated) Version
html-snippets abu 0.1.0
project-manager ale 0.18.1
code-gnu-global aus 0.2.2
gitignore cod 0.5.0
vscode-eslint dba 1.2.11
vscode-stylesheet-formatter dba 0.2.0
git-extension-pack don 0.1.2
githistory don 0.2.1
python don 0.6.7
Vue2 duc 0.1.3
gitlens eam 4.3.1
vscode-html-css ecm 0.1.7
tslint eg2 0.16.0
php-debug fel 1.11.1
php-intellisense fel 1.4.3
php-pack fel 1.0.1
auto-close-tag for 0.4.3
vue-snippets hol 0.1.2
crane Hvy 0.3.6
php-symbols lin 2.1.0
HTMLHint mka 0.3.3
prettify-json moh 0.0.3
vscode-devskim MS- 0.1.4
windowsiot ms- 0.0.20
autorest ms- 0.12.4
cpptools ms- 0.12.0
csharp ms- 1.11.0
js-atom-grammar ms- 0.1.13
typescript-javascript-grammar ms- 0.0.23
debugger-for-chrome msj 3.1.6
php-docblocker nei 1.2.0
vetur oct 0.9.1
vue-beautify pea 2.0.4
vscode-docker Pet 0.0.16
view-in-browser qin 0.0.5
java red 0.7.0
sass-indented rob 1.4.1
sc-themes Syn 1.4.1
vscode-arduino vsc 0.2.4
bootstrap-3-snippets wcw 0.1.0
better-align wwm 1.1.6
html-css-class-completion Zig 1.7.0
vscode-open-in-github ziy 1.2.7

Since the update to 1.14.0 I get an annoying indent on the first line after (say) an "if" or "for" statement which didn't used to happen. I like my curly-braces to appear on the first line after these statments and in-line with them.

Steps to Reproduce:

  1. type if( cond )
  2. hit enter
  3. cursor is indented from the "if" by one tab (in my case I have tabs set to two spaces, so the indent is two spaces from the "i" of "if")

e.g.
if( cond )
  {}

Expected:

Hitting enter should leave the cursor in-line with the "i" of "if", e.g.

if( cond )
{}

I have tried setting the following, but with no change:

  • "editor.acceptSuggestionOnEnter": "off",
  • "editor.detectIndentation": false,
  • "editor.autoIndent": false

Reproduces without extensions: Yes

edit: Fixed spacing in the examples.

@vscodebot vscodebot bot added the php PHP support issues label Jul 14, 2017
@simonl65
Copy link
Author

@vscodebot[bot] Not just php, its all languages ;-) (I know you're a bot, but one of us humans will read this!)

@simonl65
Copy link
Author

That's weird - I'm sure it reproduced without extennsions, but I just tried it without "Better Align 1.1.6" and the problem goes away!

Sorry to have bothered you.

@simonl65 simonl65 reopened this Jul 14, 2017
@simonl65
Copy link
Author

Well this is bizarre - after restarting vscode the problem has come back (even though "Better Align" is still disabled)!

@simonl65
Copy link
Author

So I've tried the following settings with no luck either:

  • "editor.detectIndentation": false,
  • "editor.autoIndent": false,
  • "javascript.format.placeOpenBraceOnNewLineForFunctions": true,
  • "javascript.format.placeOpenBraceOnNewLineForControlBlocks": true

After adding each setting I would close VSCode and then re-open it using code --disable-extensions
Incidentally, adding the two last settings don't force the open brace to the new line either 👎

@TheWyo
Copy link

TheWyo commented Jul 14, 2017

I've also been getting this since the 1.14 release, and have been able to reproduce using --disable-extensions.

Running format document with Shift+Alt+F formats correctly so it appears to be local to auto formatting while typing, not a global formatting issue.

@roblourens roblourens assigned rebornix and unassigned roblourens Jul 14, 2017
@roblourens roblourens added editor and removed php PHP support issues labels Jul 14, 2017
@simonl65
Copy link
Author

FYI: I can confirm that this has happened on another PC (with different extensions) after updating to 1.14.1

@Daivuk
Copy link

Daivuk commented Jul 16, 2017

I am also getting this in Javascript with those settings:

    "javascript.format.placeOpenBraceOnNewLineForFunctions": true,
    "javascript.format.placeOpenBraceOnNewLineForControlBlocks": true,

If I start the brace on the same line, it seems to behave properly.

@rebornix rebornix added the editor-autoindent Editor auto indentation issues label Jul 18, 2017
@rebornix
Copy link
Member

rebornix commented Jul 19, 2017

It's due to your indentNextLinePattern for JavaScript/TypeScript. Already drop some comments and discussion in #30933 , let's move our discussion there. Thank you all for your kind help.

❤️ @simonl65 @TheWyo @Daivuk

@simonl65
Copy link
Author

Not my indentNextLinePattern - that was added by VSCode in 1.14!

OK, will continue comments on #30933

@simonl65
Copy link
Author

@rebornix Closing this and not fixing the issue isn't very helpful IMHO!

@rebornix
Copy link
Member

@simonl65 sorry for using the wrong words (a typical problem of non-native speaker). We already fixed it in master and will have it with next Stable. The expected behavior will be

if () | {}

press enter will lead to

if () 
{}

Does this sound good to you?

@davidstlyoui
Copy link

davidstlyoui commented Jul 31, 2017

@rebornix Great to hear it's fixed, but no that's not the issue I am currently seeing.
Currently:

if () |

press enter:

if ()
    |

type {:

if ()
   {
        |
   }

Used to work pre-1.14
Typing { should bring it to the same level as if unless configured otherwise.

@simonl65
Copy link
Author

@rebornix No worries. However, I agree with @davidstlyoui - typing enter after the ) should result in the cursor appearing directly below the i of if (for example) as in:
if(cond)
{
  |
}

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-autoindent Editor auto indentation issues
Projects
None yet
Development

No branches or pull requests

6 participants