mirror of
https://github.com/neovim/neovim.git
synced 2026-02-20 01:09:56 +10:00
Problem: completion: various flaws in fuzzy completion
Solution: fix the issues (Girish Palya)
- Remove the brittle `qsort()` on `compl_match_array`.
- Add a stable, non-recursive `mergesort` for the internal doubly
linked list of matches.
- The sort now happens directly on the internal representation (`compl_T`),
preserving sync with external structures and making sorting stable.
- Update fuzzy match logic to enforce `max_matches` limits after
sorting.
- Remove `trim_compl_match_array()`, which is no longer necessary.
- Fixe test failures by correctly setting `selected` index and
maintaining match consistency.
- Introduce `mergesort_list()` in `misc2.c`, which operates generically
over doubly linked lists.
- Remove `pum_score` and `pum_idx` variables
fixes: vim/vim#17387
closes: vim/vim#17430
8cd42a58b4
Co-authored-by: Girish Palya <girishji@gmail.com>
35 lines
980 B
C
35 lines
980 B
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
|
|
#include "nvim/grid_defs.h"
|
|
#include "nvim/macros_defs.h"
|
|
#include "nvim/menu_defs.h" // IWYU pragma: keep
|
|
#include "nvim/types_defs.h" // IWYU pragma: keep
|
|
|
|
/// Used for popup menu items.
|
|
typedef struct {
|
|
char *pum_text; ///< main menu text
|
|
char *pum_kind; ///< extra kind text (may be truncated)
|
|
char *pum_extra; ///< extra menu text (may be truncated)
|
|
char *pum_info; ///< extra info
|
|
int pum_cpt_source_idx; ///< index of completion source in 'cpt'
|
|
int pum_user_abbr_hlattr; ///< highlight attribute for abbr
|
|
int pum_user_kind_hlattr; ///< highlight attribute for kind
|
|
} pumitem_T;
|
|
|
|
EXTERN ScreenGrid pum_grid INIT( = SCREEN_GRID_INIT);
|
|
|
|
/// state for pum_ext_select_item.
|
|
EXTERN struct {
|
|
bool active;
|
|
int item;
|
|
bool insert;
|
|
bool finish;
|
|
} pum_want;
|
|
|
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
|
# include "popupmenu.h.generated.h"
|
|
#endif
|