Diff LSP format responses that replace the whole buffer (#57269)
#29120:
https://github.com/zed-industries/zed/issues/29120#issuecomment-2819789736
On format, some language servers, rather than responding with ranges to
change, just send a response to replace the entire buffer. This PR makes
it so that when this happens, it first diffs the buffer with the new
text to replace ranges instead.
This fixes a bug where formatting would select the whole document and
scroll all the way to the bottom.
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 #29120, closes #41184
Release Notes:
- Fixed language server formatting scrolling to the bottom when the
server replaces the entire buffer.
---------
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: Amp <amp@ampcode.com>
5d5963361fkmdw committed on 9/29/2026, 5:04:24 PM· committed by GitHubparent7232ba0