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

Auto Indent Support not working for select in Go #77379

Closed
WhisperGoldstein opened this issue Jul 11, 2019 · 2 comments
Closed

Auto Indent Support not working for select in Go #77379

WhisperGoldstein opened this issue Jul 11, 2019 · 2 comments
Assignees
Labels
editor-autoindent Editor auto indentation issues under-discussion Issue is under discussion for relevance, priority, approach

Comments

@WhisperGoldstein
Copy link

Auto indent moves case statements to the same level as the select when saving. Example:

select {
case receivedMsg := <-msgCh:
	fmt.Println(receivedMsg)
case receivedError := <-errCh:
	fmt.Println(receivedError)
default:
	fmt.Println("no messages received")
}

Running VSCode v 1.36.1

The language-configuration.json file for go shows:

...
"indentationRules": { "increaseIndentPattern": "^.*(\\bcase\\b.*:|\\bdefault\\b:|(\\b(func|if|else|switch|select|for|struct)\\b.*)?{[^}\"']*|\([^)"']*)$", "decreaseIndentPattern": "^\\s*(\\bcase\\b.*:|\\bdefault\\b:|}[)}]*[),]?|\\)[,]?)$" },
...

@ramya-rao-a ramya-rao-a transferred this issue from microsoft/vscode-go Jul 15, 2019
@ramya-rao-a ramya-rao-a changed the title Auto Indent Support not working for select Auto Indent Support not working for select in Go Jul 15, 2019
@vscodebot vscodebot bot added the editor-autoindent Editor auto indentation issues label Jul 15, 2019
@ramya-rao-a
Copy link
Contributor

Since the indentation rules for Go are in VS Code, moved this issue from vscode-go to vscode.

https://github.com/microsoft/vscode/blob/master/extensions/go/language-configuration.json

@sbatten sbatten assigned rebornix and unassigned sbatten Jul 15, 2019
@rebornix rebornix added the bug Issue identified by VS Code Team member as probable bug label Jul 26, 2019
@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 labels Nov 3, 2020
@rebornix
Copy link
Member

rebornix commented Nov 3, 2020

This is due to the limited architecture (regex based indentation rules and only support limited code styles), we may want to consider using formatters if they exist for indenation adjustment (if interested, we can discuss in #19847).

For this particular issue, if the indentation rules are leading to more trouble than having no auto indent, you can set editor.autoIndent to advanced to disable the regex based indentation adjustment or use auto formatting (editor.formatOnType, editor.formatOnPaste). As we don't have an easy good-enough fix for it, we close it for now and explore better solutions through issues like (#19847, #34621 or #66235).

@rebornix rebornix closed this as completed Nov 3, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-autoindent Editor auto indentation issues under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

4 participants