Skip to content

Add doNotAddAttributeQuotes setting to disable automatic quotes - #129284

Merged
Martin Aeschlimann (aeschli) merged 3 commits into
microsoft:mainfrom
ssigwart:noQuotes
Oct 15, 2021
Merged

Martin Aeschlimann (aeschli) merged 3 commits into
microsoft:mainfrom
ssigwart:noQuotes

Conversation

@ssigwart

@ssigwart Stephen Sigwart (ssigwart) commented Jul 24, 2021 •

Copy link
Copy Markdown
Contributor

This depends on microsoft/vscode-html-languageservice#112

This allows users to disable the automatic quotes after an HTML attribute. I'm not sure the best way to test this since it depends on the pull request in microsoft/vscode-html-languageservice. I tested by manually modifying extensions/html-language-features/server/node_modules/vscode-html-languageservice/lib/umd/services/htmlCompletion.js to apply the changes.

A simple test is to use following and trigger the class completion:

<div clas|

With this setting enabled, it should be class=|, not class="|".

"default": true,
"description": "%html.autoClosingTags%"
},
"html.doNotAddAttributeQuotes": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should follow the style of the existing settings, e.g. html.completion.attributeQuotes

@aeschli

Copy link
Copy Markdown
Contributor

I'd rather avoid new settings as they make the product more complex and add are costly to maintain.
So before adding a setting I'd like to see more user request for it.

@ssigwart

Copy link
Copy Markdown
Contributor Author

Thanks, Martin Aeschlimann (@aeschli). Where would other users request it? Should I add an issue so it can go into the backlog candidate flow.

Also, do you think I'd be able to write an extension to accomplish this? I can't think of a way without writing a whole LSP extension for HTML, which would be overkill.

For reference, I personally prefer typing the quote myself. I can probably train myself to stop type the quote, but the bigger issue is that is seems like VSCode doesn't recognize trigger characters if they were part of a completion. That seems to be the issue in zignd/HTML-CSS-Class-Completion#235 and gencer/SCSS-Everywhere#36 for CSS completion. Currently, the way to work around that is to let class="|" auto-complete, then hit backspace, then type the quote and CSS completion will work. If the quotes weren't auto-inserted, it would be more intuitive.

Alternatively, would it be acceptable to write a patch where if you have editor.autoClosingOvertype set to never and type " in class="|" just after it's inserted, it will assume you meant to type the opening brace an overwrite it similar to the editor.autoClosingOvertype setting? Currently, it winds up as class=""|".

@aeschli

Martin Aeschlimann (aeschli) commented Aug 18, 2021 •

Copy link
Copy Markdown
Contributor

Yes, an issue that goes through backlog candidate would be the way to get other users feedback and votes.

I would be more open to it we could make setting a bit more general. Some users might prefer single quotes
html.completion.attributeDefaultValue=empty | singleQuotes | doubleQuotes

@ssigwart

Copy link
Copy Markdown
Contributor Author

Thanks, Martin Aeschlimann (@aeschli). I like that idea. I updated this pull request and microsoft/vscode-html-languageservice#112 to do that. I also opened #131144 to track if there's interest in this.

@ssigwart

Copy link
Copy Markdown
Contributor Author

Martin Aeschlimann (@aeschli), I updated this to match the changes in microsoft/vscode-html-languageservice#112. I rebased it and now there's an error with typescript, which I didn't touch, so I ignored it. Please let me know if I should rebased at a later point once that error is resolved.

@aeschli

Copy link
Copy Markdown
Contributor

That looks good, thanks Stephen Sigwart (@ssigwart) ! I'll merge it next week.

@ssigwart

Copy link
Copy Markdown
Contributor Author

Thanks, Martin Aeschlimann (@aeschli). I'm really looking forward to this setting.

@aeschli

Copy link
Copy Markdown
Contributor

Thanks Stephen Sigwart (@ssigwart) !

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants