Allow formatting selections via LSP (#18752)
Release Notes: - Added a new `editor: format selections` action that allows formatting only the currently selected text via the primary language server. --------- Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
This commit is contained in:
co-authored by
Thorsten Ball
parent
eb76065ad3
commit
84df3a0cad
@@ -27,6 +27,7 @@ use rpc::proto::{self, update_view, PeerId};
|
||||
use settings::Settings;
|
||||
use workspace::item::{Dedup, ItemSettings, SerializableItem, TabContentParams};
|
||||
|
||||
use project::lsp_store::FormatTarget;
|
||||
use std::{
|
||||
any::TypeId,
|
||||
borrow::Cow,
|
||||
@@ -722,7 +723,12 @@ impl Item for Editor {
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
if format {
|
||||
this.update(&mut cx, |editor, cx| {
|
||||
editor.perform_format(project.clone(), FormatTrigger::Save, cx)
|
||||
editor.perform_format(
|
||||
project.clone(),
|
||||
FormatTrigger::Save,
|
||||
FormatTarget::Buffer,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user