You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Select the latter function only and run "Format selections". The entire file is formatted, instead of just the latter function.
If the Rust language server (rust-analyzer) is used instead, Zed cancels the operation with an error message saying the LSP does not support formatting selections. This is a reasonable behavior that I would also expect for external formatters, if Zed doesn't intend to implement its own logic to limit the scope of formatting performed by an exernal formatter.
IIRC, rustfmt is not able to format partial formats, so the example is quite bad. Does it work with something that's able to format partially?
There is no standardized interface for external formatters to format partially. This should either fail with an error message, or Zed would have to implement a way to limit the scope of formatting when using an external formatter that does not natively support partial formatting. An error message is better than doing the wrong thing.
Summary
When an external formatter is configured, attempting to format only selected lines instead formats the entire file.
To reproduce:
Create a new project and place these contents in the project
settings.json
:Then edit a Rust file and place this content in it:
Select the latter function only and run "Format selections". The entire file is formatted, instead of just the latter function.
If the Rust language server (rust-analyzer) is used instead, Zed cancels the operation with an error message saying the LSP does not support formatting selections. This is a reasonable behavior that I would also expect for external formatters, if Zed doesn't intend to implement its own logic to limit the scope of formatting performed by an exernal formatter.
Zed Version and System Specs
Zed: v0.173.10 (Zed)
OS: Linux Wayland arch unknown
Memory: 15.3 GiB
Architecture: x86_64
GPU: Intel(R) Iris(R) Xe Graphics (TGL GT2) || Intel open-source Mesa driver || Mesa 24.3.4-arch1.1
The text was updated successfully, but these errors were encountered: