editor: Improve code completions by prioritizing prefix matching (#29456)

- Use common prefix length-based matching as primary criteria.
- Test added for multiple cases.

Before:
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/8c653225-cac2-41bd-95f0-0fb8724284c9"
/>

After:
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/a3d59399-cff2-435d-9b56-69a530f35da4"
/>

Release Notes:

- Fixed issues with code completions where they wouldn't show
completions with matched prefix at top.
This commit is contained in:
Smit Barmase 2025-04-26 17:15:48 +05:30 committed by GitHub
parent ec5821f76d
commit f2b4004c00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 220 additions and 34 deletions

View file

@ -10732,7 +10732,7 @@ async fn test_completion(cx: &mut TestAppContext) {
.confirm_completion(&ConfirmCompletion::default(), window, cx)
.unwrap()
});
cx.assert_editor_state("editor.clobberˇ");
cx.assert_editor_state("editor.closeˇ");
handle_resolve_completion_request(&mut cx, None).await;
apply_additional_edits.await.unwrap();
}
@ -13982,7 +13982,7 @@ async fn test_completions_in_languages_with_extra_word_characters(cx: &mut TestA
{
assert_eq!(
completion_menu_entries(&menu),
&["bg-blue", "bg-red", "bg-yellow"]
&["bg-red", "bg-blue", "bg-yellow"]
);
} else {
panic!("expected completion menu to be open");