Gate Format Selections on whether the active formatter can actually format ranges#53178
Conversation
|
@SomeoneToIgnore Please review. |
Format Selections on whether the active formatter can actually format ranges.Format Selections on whether the active formatter can actually format ranges
f115af0 to
216ac53
Compare
|
Sorry, |
Thanks, @SomeoneToIgnore. I was wondering why tests are failing all of a sudden and trying to look into issue without much luck. |
|
Seems to be fixed? |
216ac53 to
b168ff0
Compare
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Thank you, the way to disable the action seems way better than my proposal, but the implementation is quite odd.
Let's clean it up, as it looks we can do it much simpler.
ebf2a32 to
05c5247
Compare
Hi @SomeoneToIgnore, I've cleaned it up based on your suggestions. |
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
I've pushed a few fixes as there was a lot of unneeded allocations all over the place.
There's one very odd place left that we need to discuss.
b59628f to
c9a83ba
Compare
c9a83ba to
e4ab8ee
Compare
Signed-off-by: Pratik Karki <[email protected]>
Signed-off-by: Pratik Karki <[email protected]>
Signed-off-by: Pratik Karki <[email protected]>
e4ab8ee to
09f1da5
Compare
|
Sorry, |
Apologies, I agreed to the change, but my commits during rebase, I added wrong changes and committed them. I'll amend and push again. |
Signed-off-by: Pratik Karki <[email protected]>
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Thank you.
Given all the back-and-forth, I'll merge this after the next release this Wednesday, to be on a safe side.
Sure, @SomeoneToIgnore. Thanks for reviewing this and giving me feedback. |
… format ranges (zed-industries#53178) ## What Changed - compute range-format support from formatter configuration and language-server capabilities - show `Format Selections` only when at least one selected buffer has a range-capable formatter - keep Prettier-supported range formatting available without depending on LSP support - hide the action for formatter modes that cannot honor selections, such as external-command and code-action formatters - keep the action handler safe by rechecking support and returning early when range formatting is unavailable - restrict capability checks to the servers actually registered for the current buffer - add regression coverage for supported, unsupported, and mixed-server cases - document when `Format Selections` is available in both action docs and user docs Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes zed-industries#25796 Release Notes: - Improved `Format Selections` so it is only shown when the active formatter supports range formatting. Testing I did: Here are the formatters I used: <img width="829" height="434" alt="Screenshot_20260405_102047" src="https://github.com/user-attachments/assets/cae4a238-277e-4188-873f-189e9f098699" /> Note: I've chosen three formatters: 1. Prettier, which supports range formatting 2. clangd (LSP) which also supports range formatting 3. gopls which do not support range formatting [Screencast_20260405_102431.webm](https://github.com/user-attachments/assets/69ce3f95-0b73-46a0-853d-3b5be6329dde) --------- Signed-off-by: Pratik Karki <[email protected]> Co-authored-by: Kirill Bulatov <[email protected]>
What Changed
Format Selectionsonly when at least one selected buffer has a range-capable formatterFormat Selectionsis available in both action docs and user docsSelf-Review Checklist:
Closes #25796
Release Notes:
Format Selectionsso it is only shown when the active formatter supports range formatting.Testing I did:
Here are the formatters I used:

Note: I've chosen three formatters:
Screencast_20260405_102431.webm