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

The setting volar.format.initialIndent is ignored in script setup files #1847

Closed
michaeldaw opened this issue Sep 8, 2022 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@michaeldaw
Copy link

The initial indent feature introduced in version 0.40.2 includes the ability to be turned off with using the setting "volar.format.initialIndent". However, this setting is only effective when formatting an entire document. While typing code, the setting is ignored.
The result is that unnecessary indents are added to new lines while typing.
Link to details of original suggested feature and development: #1806

Demo of this problem occurring in version 0.40.13:
code

@michaeldaw michaeldaw changed the title The setting "" is ignored in script setup files The setting volar.format.initialIndent is ignored in script setup files Sep 8, 2022
@johnsoncodehk
Copy link
Member

johnsoncodehk commented Sep 13, 2022

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Sep 13, 2022
@michaeldaw
Copy link
Author

Thank you for clearing this up.

From what I can tell through experimentation, the indentation rules in the file vue-language-configuration.json introduced in 0.40.2 result in the situation where an extra indent is added after a line that includes < and >, which means a line in the script setup section like the following will get an unwanted indent on the next line:

const variable = ref<number>(0);

or

const variable: Array<string> = [];

etc.

The user probably wouldn't see this unless using Typescript.
You can see this happen at the end of the gif I uploaded in the original post at the very end.

Removing the "increaseIndentPattern" line in that file restores the original functionality, but of course ruins whatever functionality this line is meant to provide. I'm afraid I'm not well enough versed in Regex to know how to specifically modify that pattern to stop this extra indent from happening while retaining the intended indent rules for HTML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants