lsp: Support on-type formatting request with newlines (#44882)
We called out to `request_on_type_formatting` only in handle_input function, but newlines are actually handled by editor::Newline action. Closes #12383 Release Notes: - Added support for on-type formatting with newlines.
This commit is contained in:
@@ -5018,6 +5018,9 @@ impl Editor {
|
||||
|
||||
this.change_selections(Default::default(), window, cx, |s| s.select(new_selections));
|
||||
this.refresh_edit_prediction(true, false, window, cx);
|
||||
if let Some(task) = this.trigger_on_type_formatting("\n".to_owned(), window, cx) {
|
||||
task.detach_and_log_err(cx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5082,6 +5085,9 @@ impl Editor {
|
||||
}
|
||||
}
|
||||
editor.edit(indent_edits, cx);
|
||||
if let Some(format) = editor.trigger_on_type_formatting("\n".to_owned(), window, cx) {
|
||||
format.detach_and_log_err(cx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5144,6 +5150,9 @@ impl Editor {
|
||||
}
|
||||
}
|
||||
editor.edit(indent_edits, cx);
|
||||
if let Some(format) = editor.trigger_on_type_formatting("\n".to_owned(), window, cx) {
|
||||
format.detach_and_log_err(cx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5454,7 +5463,7 @@ impl Editor {
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<Task<Result<()>>> {
|
||||
if input.len() != 1 {
|
||||
if input.chars().count() != 1 {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user