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

'Format Selection' and 'Format Document' not language aware #70995

Closed
Yzrsah opened this issue Mar 23, 2019 · 8 comments
Closed

'Format Selection' and 'Format Document' not language aware #70995

Yzrsah opened this issue Mar 23, 2019 · 8 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) formatting Source formatter issues under-discussion Issue is under discussion for relevance, priority, approach

Comments

@Yzrsah
Copy link

Yzrsah commented Mar 23, 2019

Format Selection editor.action.formatSelection and Format Document editor.action.formatDocument do not utilize the language mode for the file.

If I'm working with JavaScript and I try to use these commands, I will be prompted to choose from a menu every time:
Multiple languages

Having to select the same redundant selection from a menu every time makes this one too unusable.

There does not seem to be a way to set the "Default Formatter" for a language

@jrieken jrieken added formatting Source formatter issues under-discussion Issue is under discussion for relevance, priority, approach labels Mar 25, 2019
@jrieken
Copy link
Member

jrieken commented Mar 25, 2019

See #41882 (comment) for some background. What this means is that you have three extensions installed that all advertise that they can configure the current document (not which which that is). The prompt is shown the make clear what happens and to make you chose or disable/uninstall conflicting formatters.

@jrieken jrieken added the *duplicate Issue identified as a duplicate of another issue(s) label Mar 25, 2019
@vscodebot
Copy link

vscodebot bot commented Mar 25, 2019

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Mar 25, 2019
@jrieken
Copy link
Member

jrieken commented Mar 25, 2019

fyi - I have pushed a change so that format document still picks some formatter (it now prints a status bar message which it picked). closing quick pick is a separate command which doesn't take the keybinding away anymore

@Yzrsah
Copy link
Author

Yzrsah commented Mar 26, 2019

@jrieken Thank you very much for the update.

The update helps with ease of use, but, it picked the wrong formatter for the project. The reason I have multiple formatters is because different projects are using different formatters. I would love to be able to set the "defaultFormatter" in the workspace settings so that each workspace can use the correct formatter. I hope you will consider that one because I think that people will request it in the future.

In the workspace it could be like

    "[javascript]": {
        "editor.defaultFormatter": "Beautify"
    },

@Yzrsah
Copy link
Author

Yzrsah commented Mar 28, 2019

@jrieken There was no solution working because we are forced to enable and disable extensions every time we switch projects, it's an ongoing problem / not resolved

@jrieken
Copy link
Member

jrieken commented Apr 1, 2019

@Yzrsah How about defining the setting on the workspace-level, e.g in the .vscode/settings.json file?

@Yzrsah
Copy link
Author

Yzrsah commented Apr 7, 2019

@jrieken I'm sorry I didn't respond sooner

That would be fantastic! And would be very useful for working with different projects. Thanks so much for your consideration about it.

@Yzrsah
Copy link
Author

Yzrsah commented Apr 7, 2019

@jrieken I just got a surprise to discover editor.defaultFormatter in the Insiders build!

The popup prompted me to select a default formatter and it worked excellently!

Thank you so much, this really helps a lot with the projects

@vscodebot vscodebot bot locked and limited conversation to collaborators May 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) formatting Source formatter issues under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

2 participants