sveltejs/language-tools

Formatter pop-up

Closed this issue · 2 comments

Describe the bug

A modal pop-up appears whenever one attempts to format a line or section of svelte code:

Configure Default Formatter

Extension 'Svelte for VS Code' is configured as formatter but it can only format 'Svelte'-files as a whole, not selections or parts of it.
[CANCEL] [CONFIGURE...]

Pressing [CONFIGURE] simply offers a drop-down for you to select another formatter.

This modal pop-up allows no other interaction. While I understand the the modal is "owned" by VS Code, it is the svelte formatter which triggers it.

Reproduction

Open or create a project with Svelte. Highlight a line or section. Press CTRL-K, CTRL-F or if using the Vim emulator press == or right-click the selection and select 'Format Selection' from the context menu. Observe the popup.

Expected behaviour

The best outcome would be that the highlighted section is formatted. The worst outcome is that the work flow is interrupted by a modal pop-up concerning a trivial matter.

Less good, but better than what's happening now:

  • The entire file is formatted or
  • none of the file is formatted

System Info

  • OS: Ubuntu 22
  • IDE: VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

image

While work-arounds are possible, they involve changing default keybindings or altering workflow.

Duplicate of #929. As the error message suggested, format selection is not supported right now. We rely on Prettier for formatting but Prettier doesn't have API for plugin to add support for format selection.