Fix code action formatters creating separate transaction (#26311)
Closes #24588 Closes #25419 Restructures `LspStore.format_local` a decent bit in order to make how the transaction history is preserved more clear, and in doing so fix various bugs with how the transaction history is handled during a format request (especially when formatting in remote dev) Release Notes: - Fixed an issue that prevented formatting from working when working with remote dev - Fixed an issue when using code actions as a format step where the edits made by the code actions would not be grouped with the other format edits in the undo history
This commit is contained in:
parent
1cf252f8eb
commit
274124256d
3 changed files with 599 additions and 340 deletions
File diff suppressed because it is too large
Load diff
|
@ -704,7 +704,7 @@ pub(super) async fn format_with_prettier(
|
||||||
prettier_store: &WeakEntity<PrettierStore>,
|
prettier_store: &WeakEntity<PrettierStore>,
|
||||||
buffer: &Entity<Buffer>,
|
buffer: &Entity<Buffer>,
|
||||||
cx: &mut AsyncApp,
|
cx: &mut AsyncApp,
|
||||||
) -> Option<Result<crate::lsp_store::FormatOperation>> {
|
) -> Option<Result<language::Diff>> {
|
||||||
let prettier_instance = prettier_store
|
let prettier_instance = prettier_store
|
||||||
.update(cx, |prettier_store, cx| {
|
.update(cx, |prettier_store, cx| {
|
||||||
prettier_store.prettier_instance_for_buffer(buffer, cx)
|
prettier_store.prettier_instance_for_buffer(buffer, cx)
|
||||||
|
@ -738,7 +738,6 @@ pub(super) async fn format_with_prettier(
|
||||||
let format_result = prettier
|
let format_result = prettier
|
||||||
.format(buffer, buffer_path, ignore_dir, cx)
|
.format(buffer, buffer_path, ignore_dir, cx)
|
||||||
.await
|
.await
|
||||||
.map(crate::lsp_store::FormatOperation::Prettier)
|
|
||||||
.with_context(|| format!("{} failed to format buffer", prettier_description));
|
.with_context(|| format!("{} failed to format buffer", prettier_description));
|
||||||
|
|
||||||
Some(format_result)
|
Some(format_result)
|
||||||
|
|
|
@ -4699,19 +4699,6 @@ impl Project {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_code_actions(code_actions: &HashMap<String, bool>) -> Vec<lsp::CodeActionKind> {
|
|
||||||
code_actions
|
|
||||||
.iter()
|
|
||||||
.flat_map(|(kind, enabled)| {
|
|
||||||
if *enabled {
|
|
||||||
Some(kind.clone().into())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct PathMatchCandidateSet {
|
pub struct PathMatchCandidateSet {
|
||||||
pub snapshot: Snapshot,
|
pub snapshot: Snapshot,
|
||||||
pub include_ignored: bool,
|
pub include_ignored: bool,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue