zed/docs/src
Pratik Karki 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
..
ai docs: Fix stale MCP extension links (#53946) 2026-04-14 22:37:50 -07:00
collaboration docs: Remove Preview callouts for stable release (#50736) 2026-03-04 15:10:13 -05:00
development Removal of mold/wild scripts and mentions in docs (#53078) 2026-04-08 21:20:02 +03:00
extensions language_core: Introduce fallback highlights (#52575) 2026-04-02 12:52:42 +00:00
languages docs: Add Dexter language server to Elixir documentation (#53793) 2026-04-15 13:55:32 +00:00
migrate editor: Add configurable hover delay (#53504) 2026-04-13 09:46:19 +03:00
reference editor: Add configurable hover delay (#53504) 2026-04-13 09:46:19 +03:00
all-actions.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
appearance.md Add hotkeys and actions for toggle light and dark theme (#49027) 2026-03-12 21:35:42 +02:00
authentication.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
command-palette.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
completions.md Remove Supermaven-related code from Zed (#50537) 2026-03-02 22:18:49 +00:00
configuring-languages.md Gate Format Selections on whether the active formatter can actually format ranges (#53178) 2026-04-16 09:11:22 +03:00
configuring-zed.md Add vim/emacs modeline support (#49267) 2026-03-25 03:15:51 +00:00
debugger.md docs: Remove Preview callouts for stable release (#50736) 2026-03-04 15:10:13 -05:00
dev-containers.md docs: Add AI SEO frontmatter (#48559) 2026-02-11 13:10:31 -08:00
development.md Improve documentation for ETW profiling (#50426) 2026-02-28 23:03:49 -05:00
diagnostics.md docs: Add AI SEO frontmatter (#48559) 2026-02-11 13:10:31 -08:00
editing-code.md docs: SEO content improvements for AI section (#49128) 2026-02-13 13:05:57 -08:00
environment.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
extensions.md Remove text thread and slash command crates (#52757) 2026-03-31 17:55:05 +02:00
finding-navigating.md Remove search_on_input from docs (#52435) 2026-03-25 18:41:37 +00:00
getting-started.md docs: Remove Preview callouts for stable release (#50736) 2026-03-04 15:10:13 -05:00
git.md docs: Update File History menu label from Open to View (#49859) 2026-03-01 10:02:33 +00:00
globs.md docs: Remove Preview callouts for stable release (#50119) 2026-02-25 14:16:54 -06:00
helix.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
icon-themes.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
installation.md docs: Add AI SEO frontmatter (#48559) 2026-02-11 13:10:31 -08:00
key-bindings.md Fix docs validation to detect unknown keys (#49660) 2026-02-19 20:46:21 -05:00
languages.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
linux.md Deprioritize Flathub (#53857) 2026-04-14 20:42:16 -06:00
macos.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
modelines.md Add vim/emacs modeline support (#49267) 2026-03-25 03:15:51 +00:00
multibuffers.md docs: Add AI SEO frontmatter (#48559) 2026-02-11 13:10:31 -08:00
outline-panel.md docs: Remove Preview callouts for stable release (#50736) 2026-03-04 15:10:13 -05:00
performance.md docs: Center and re-flow perf images (#53004) 2026-04-02 10:24:43 -06:00
quick-start.md docs: Reorganize introduction (#41387) 2025-10-28 17:39:40 -03:00
remote-development.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
repl.md docs: Remove Preview callouts for stable release (#50119) 2026-02-25 14:16:54 -06:00
roles.md docs: Add roles page under Account & Privacy section (#51413) 2026-03-13 10:48:54 -07:00
running-testing.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
semantic-tokens.md extension_host: Allow extensions to define semantic highlighting rules (#49282) 2026-03-02 17:54:53 +01:00
snippets.md docs: Remove outdated reference to simple-completion-language-server (#50732) 2026-03-04 18:45:52 +00:00
SUMMARY.md Remove text thread and slash command crates (#52757) 2026-03-31 17:55:05 +02:00
tab-switcher.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
tasks.md Don't save buffers by default when running tasks (#52976) 2026-04-02 13:09:29 +00:00
telemetry.md Docs/privacy documentation refresh (#50522) 2026-03-02 11:21:07 -08:00
terminal.md docs: SEO content improvements for AI section (#49128) 2026-02-13 13:05:57 -08:00
themes.md Add hotkeys and actions for toggle light and dark theme (#49027) 2026-03-12 21:35:42 +02:00
toolchains.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
troubleshooting.md Update links to troubleshooting images (#52851) 2026-04-02 08:30:40 -06:00
uninstall.md docs: Update guide to remove user data on macOS when uninstalling Zed (#52631) 2026-03-31 05:35:04 +00:00
update.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
vim.md docs: Update mentions to "assistant panel" (#53514) 2026-04-09 10:42:21 -03:00
visual-customization.md project_panel: Add sort_order settings (#50221) 2026-04-08 18:33:00 +05:30
windows.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
worktree-trust.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00