Pratik Karki and Kirill Bulatov
b6b2b63370
Gate Format Selections on whether the active formatter can actually format ranges ( #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 #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 <pratik@prertik.com >
Co-authored-by: Kirill Bulatov <kirill@zed.dev >
2026-04-16 09:11:22 +03:00
..
2026-04-15 10:08:01 +00:00
2026-04-01 09:05:03 +00:00
2026-04-09 18:49:16 +01:00
2026-03-09 13:22:12 +01:00
2026-04-15 18:15:37 +00:00
2026-04-13 16:59:17 -07:00
2026-04-13 22:51:38 +00:00
2026-04-15 22:47:25 -07:00
2026-04-15 21:51:15 -03:00
2026-04-14 12:06:17 +03:00
2026-02-18 12:00:02 +01:00
2026-03-24 00:58:09 +01:00
2026-03-18 21:31:20 -04:00
2026-03-03 17:47:35 +01:00
2026-04-15 21:51:15 -03:00
2026-04-07 11:59:12 +02:00
2026-03-13 08:00:22 +00:00
2026-04-01 17:25:32 +00:00
2026-04-01 17:25:32 +00:00
2026-03-30 13:07:13 +00:00
2026-04-15 04:58:04 +00:00
2026-04-14 10:55:03 -04:00
2026-02-25 08:12:04 +01:00
2026-04-07 12:28:19 -03:00
2026-04-10 10:15:28 -04:00
2026-04-15 02:22:14 -04:00
2026-04-02 17:06:57 -03:00
2026-04-15 19:55:37 +00:00
2026-04-10 10:15:28 -04:00
2026-03-27 18:06:56 -07:00
2026-03-31 15:09:16 -04:00
2026-04-15 21:51:15 -03:00
2026-04-05 23:05:35 +01:00
2026-04-05 23:05:35 +01:00
2026-03-24 13:22:21 +00:00
2026-03-27 14:56:46 -07:00
2026-03-11 03:08:39 +00:00
2026-04-02 17:06:57 -03:00
2026-04-08 07:24:37 +00:00
2026-03-30 09:06:59 +00:00
2026-03-16 16:29:24 +00:00
2026-04-15 23:25:44 +00:00
2026-01-14 07:19:13 +00:00
2026-04-06 16:42:20 +00:00
2026-04-15 21:51:15 -03:00
2026-04-09 10:42:21 -03:00
2026-04-15 08:24:34 -07:00
2026-04-09 10:05:40 -04:00
2026-03-31 17:55:05 +02:00
2026-04-15 02:22:14 -04:00
2026-04-14 21:04:10 +03:00
2026-03-25 23:41:09 +00:00
2026-04-14 21:04:10 +03:00
2026-04-10 13:27:04 -04:00
2026-04-13 13:30:48 -04:00
2026-04-16 09:11:22 +03:00
2026-04-01 17:25:32 +00:00
2026-04-07 12:28:19 -03:00
2026-02-28 21:47:30 -05:00
2026-04-02 17:06:57 -03:00
2026-02-19 18:57:49 +01:00
2026-02-28 22:42:19 -05:00
2026-04-03 19:22:17 +05:30
2026-03-24 19:11:30 -04:00
2026-03-27 14:41:25 +01:00
2026-03-31 18:14:18 -07:00
2026-03-31 17:55:05 +02:00
2026-04-13 16:50:13 -07:00
2026-03-09 13:22:12 +01:00
2026-04-07 12:05:02 +02:00
2026-04-15 19:55:37 +00:00
2026-02-19 18:57:49 +01:00
2026-04-03 11:00:13 +00:00
2026-04-07 12:05:02 +02:00
2026-04-15 22:08:28 -03:00
2026-04-13 13:14:48 -03:00
2026-01-31 21:56:34 +00:00
2026-04-15 22:08:28 -03:00
2026-04-01 17:25:32 +00:00
2026-04-09 10:42:21 -03:00
2026-04-15 22:17:22 -07:00
2026-04-14 16:21:28 +02:00
2026-04-14 16:21:28 +02:00
2026-04-08 15:50:36 +00:00
2026-03-24 11:05:12 +00:00
2026-04-07 12:28:19 -03:00
2026-04-14 18:14:31 +02:00
2026-02-26 18:36:50 +01:00
2026-03-31 13:16:53 +00:00
2026-04-13 18:17:55 +03:00
2026-04-04 16:10:22 -04:00
2026-04-13 17:23:37 +00:00
2026-04-07 11:19:21 +05:30
2026-04-15 22:08:28 -03:00
2026-03-28 18:41:33 -04:00
2026-04-10 09:20:38 +00:00
2026-02-12 00:28:17 +00:00
2026-03-12 15:34:09 -07:00
2026-03-07 11:05:10 +01:00
2026-04-15 21:51:15 -03:00
2026-04-08 18:39:17 -04:00
2026-04-07 12:28:19 -03:00
2026-04-02 12:52:42 +00:00
2026-04-07 12:28:19 -03:00
2026-04-15 10:11:44 +02:00
2026-04-07 12:28:19 -03:00
2026-04-07 12:28:19 -03:00
2026-03-25 12:07:34 -06:00
2026-04-01 17:25:32 +00:00
2026-04-06 16:42:20 +00:00
2026-04-15 21:06:21 -07:00
2026-04-01 17:25:32 +00:00
2026-02-03 15:51:40 -05:00
2026-03-24 00:58:09 +01:00
2026-03-06 16:49:55 +00:00
2026-03-17 08:36:37 +01:00
2026-04-10 19:11:27 +05:30
2026-04-09 21:43:51 +05:30
2025-12-30 07:49:01 -03:00
2026-04-15 15:03:53 +00:00
2026-03-27 14:41:25 +01:00
2026-04-09 10:42:21 -03:00
2026-04-07 22:37:00 +00:00
2026-02-17 10:41:10 +00:00
2026-02-20 13:36:04 +00:00
2026-04-14 11:10:31 +00:00
2026-04-15 21:51:15 -03:00
2026-04-15 02:21:56 -04:00
2026-04-15 21:51:15 -03:00
2026-04-09 10:42:21 -03:00
2026-03-27 14:41:25 +01:00
2026-04-07 12:28:19 -03:00
2026-03-23 12:48:49 +00:00
2026-04-01 17:25:32 +00:00
2026-04-07 14:15:33 +00:00
2026-03-13 14:13:12 -03:00
2026-03-31 17:55:05 +02:00
2026-04-07 12:44:19 -03:00
2026-04-08 00:34:54 +00:00
2026-03-31 12:48:22 +03:00
2026-04-16 09:11:22 +03:00
2026-02-19 18:57:49 +01:00
2026-04-15 21:51:15 -03:00
2026-04-09 16:38:07 +00:00
2026-03-26 13:48:18 +00:00
2026-04-15 19:55:37 +00:00
2026-04-15 10:18:10 +01:00
2025-12-15 13:30:13 +00:00
2026-04-15 23:25:44 +00:00
2026-04-15 09:07:53 +00:00
2026-04-10 02:22:55 +00:00
2026-04-15 19:55:37 +00:00
2026-04-10 09:20:38 +00:00
2026-03-09 13:22:12 +01:00
2026-03-21 14:05:30 +01:00
2026-04-13 09:07:09 +00:00
2026-04-06 17:19:29 -03:00
2026-03-07 04:11:45 +00:00
2026-03-27 14:41:25 +01:00
2026-04-14 16:20:05 +01:00
2026-03-18 12:05:57 -07:00
2026-04-13 22:51:38 +00:00
2026-04-15 04:58:04 +00:00
2026-03-25 12:07:34 -06:00
2026-04-02 00:44:53 +00:00
2026-04-15 11:59:49 +03:00
2026-03-16 23:49:34 -04:00
2026-04-15 22:08:28 -03:00
2026-01-26 13:49:26 +00:00
2026-02-12 00:28:17 +00:00
2026-03-10 20:25:12 +00:00
2026-03-21 14:05:30 +01:00
2026-03-29 14:43:05 +00:00
2026-03-31 08:06:37 -06:00
2025-11-24 13:34:04 +01:00
2026-04-14 23:26:23 -07:00
2026-04-02 13:09:29 +00:00
2026-04-07 06:14:00 +00:00
2026-01-28 16:36:44 -08:00
2026-03-30 07:56:00 -07:00
2026-04-15 17:38:47 +00:00
2026-04-01 17:25:32 +00:00
2026-04-09 12:32:27 +00:00
2026-03-27 14:41:25 +01:00
2026-03-27 14:41:25 +01:00
2026-04-07 23:41:34 +00:00
2026-04-10 09:20:38 +00:00
2026-02-28 21:47:30 -05:00
2026-04-14 09:27:06 -04:00
2026-04-01 17:25:32 +00:00
2026-04-15 22:08:28 -03:00
2026-03-13 19:37:18 -03:00
2026-03-27 15:31:49 +00:00
2026-03-27 14:41:25 +01:00
2026-04-09 14:11:55 -04:00
2026-04-09 10:42:21 -03:00
2026-04-08 22:29:16 +03:00
2026-03-19 12:53:26 -04:00
2026-03-09 13:22:12 +01:00
2026-04-07 12:28:19 -03:00
2026-03-27 14:41:25 +01:00
2026-04-15 21:51:15 -03:00
2026-04-15 03:47:19 +00:00
2026-02-19 18:57:49 +01:00
2026-04-09 10:42:21 -03:00
2026-04-15 15:08:53 +00:00
2026-04-13 22:51:38 +00:00
2026-04-02 17:06:57 -03:00
2026-04-02 17:06:57 -03:00
2026-04-06 16:29:37 -04:00
2026-03-03 08:37:58 +00:00
2026-02-11 11:24:04 +00:00
2025-12-05 17:23:06 +00:00