Fix bugs with multicursor completions (#28586)

Release Notes:

- Fixed completions with multiple cursors leaving duplicated prefixes.
- Fixed crash when accepting a completion in a multibuffer with multiple
cursors.
- Vim: improved `single-repeat` after accepting a completion, now
pressing `.` to replay the completion will re-insert the completion text
at the cursor position.
This commit is contained in:
João Marcos 2025-04-14 15:09:28 -03:00 committed by GitHub
parent 47b663a8df
commit ff41be30dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 341 additions and 76 deletions

View file

@ -1,8 +1,7 @@
pub mod editor_lsp_test_context;
pub mod editor_test_context;
use std::sync::LazyLock;
pub use crate::rust_analyzer_ext::expand_macro_recursively;
use crate::{
DisplayPoint, Editor, EditorMode, FoldPlaceholder, MultiBuffer,
display_map::{DisplayMap, DisplaySnapshot, ToDisplayPoint},
@ -11,11 +10,11 @@ use gpui::{
AppContext as _, Context, Entity, Font, FontFeatures, FontStyle, FontWeight, Pixels, Window,
font,
};
use pretty_assertions::assert_eq;
use project::Project;
use std::sync::LazyLock;
use util::test::{marked_text_offsets, marked_text_ranges};
pub use crate::rust_analyzer_ext::expand_macro_recursively;
#[cfg(test)]
#[ctor::ctor]
fn init_logger() {
@ -96,8 +95,12 @@ pub fn assert_text_with_selections(
cx: &mut Context<Editor>,
) {
let (unmarked_text, text_ranges) = marked_text_ranges(marked_text, true);
assert_eq!(editor.text(cx), unmarked_text);
assert_eq!(editor.selections.ranges(cx), text_ranges);
assert_eq!(editor.text(cx), unmarked_text, "text doesn't match");
assert_eq!(
editor.selections.ranges(cx),
text_ranges,
"selections don't match",
);
}
// RA thinks this is dead code even though it is used in a whole lot of tests