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

[LS] Suggested import returns string with CRLFs, double quotes and no indent #854

Closed
non25 opened this issue Mar 3, 2021 · 2 comments
Closed

Comments

@non25
Copy link

non25 commented Mar 3, 2021

svelteserver screenshots

before

after

Contrary to tsserver, which inserts imports without CRLFs and uses quote variant that is prevalent in this file.

tsserver screenshots

single-quotes-before

single-quotes-after

double-quotes-before

double-quotes-after

Edit: I've also tried converting Promise-based function to an async in svelte file, it inserts CRLFs too, indent is messed up, but at least it doesn't touch my single quotes: 😄

I guess vcsode just autoformats everything after code actions so it goes unnoticed?
My autoformatter doesn't strip CRs from LFs. 🤔

@dummdidumm
Copy link
Member

dummdidumm commented Mar 4, 2021

These options are passed into the typescript language service by us, and it works in VS Code. You likely need to pass TypeScript's user preferences into the language server similar to this.

The indent is a different issue indepent of the configuration.

dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Mar 19, 2021
Use indentation of first line of imports to determine the indentation of the following lines
sveltejs#854
dummdidumm added a commit that referenced this issue Mar 19, 2021
Use indentation of first line of imports to determine the indentation of the following lines
#854
dummdidumm pushed a commit that referenced this issue Dec 6, 2021
Typescript defaults to CRLF if host.getNewLine is not implemented and if there's no user config
#854
dummdidumm pushed a commit that referenced this issue Aug 30, 2022
#1579
#854

Adds the format options from VS Code TS/JS + overrides some of them with Prettier options
@jasonlyu123
Copy link
Member

With 106.0.0. The behaviour now is:

  1. If the current file contains LF but not CRLF, use LF otherwise use the system default. i.e. require('os').EOL
  2. base indent for the module and instance script tag is now 4 by default. If you have a prettier config it would use the tabWidth config. If you don't want the base indent set svelteIndentScriptAndStyle to false in your prettier config.
  3. quoteStyle can already be configured with typescript.preferences.quoteStyle or javascript.preferences.quoteStyle

That check all the boxes. So I think we can close this now. If there's anything I missed, feel free to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants