Fix handling of selection ranges for format selections in multibuffer (#22929)

Before this change it was using the same multibuffer point ranges in
every buffer, which only worked correctly for singleton buffers.

Release Notes:

- Fixed handling of selection ranges when formatting selections within a
multibuffer.

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
This commit is contained in:
Michael Sloan 2025-01-09 17:17:04 -07:00 committed by GitHub
parent 29aa291d28
commit 685dd77d97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 170 additions and 119 deletions

View file

@ -59,6 +59,7 @@ use lsp::{
LanguageServerId, LanguageServerName, MessageActionItem,
};
use lsp_command::*;
use lsp_store::LspFormatTarget;
use node_runtime::NodeRuntime;
use parking_lot::Mutex;
pub use prettier_store::PrettierStore;
@ -2632,13 +2633,13 @@ impl Project {
pub fn format(
&mut self,
buffers: HashSet<Model<Buffer>>,
target: LspFormatTarget,
push_to_history: bool,
trigger: lsp_store::FormatTrigger,
target: lsp_store::FormatTarget,
cx: &mut ModelContext<Project>,
) -> Task<anyhow::Result<ProjectTransaction>> {
self.lsp_store.update(cx, |lsp_store, cx| {
lsp_store.format(buffers, push_to_history, trigger, target, cx)
lsp_store.format(buffers, target, push_to_history, trigger, cx)
})
}