mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
vim-patch:9.1.1284: not possible to configure pum truncation char
Problem: not possible to configure the completion menu truncation
character
Solution: add the "trunc" suboption to the 'fillchars' setting to
configure the truncation indicator (glepnir).
closes: vim/vim#17006
b87620466c
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
@@ -577,6 +577,7 @@ void pum_redraw(void)
|
||||
int thumb_pos = 0;
|
||||
int thumb_height = 1;
|
||||
int n;
|
||||
schar_T fcs_trunc = curwin->w_p_fcs_chars.trunc;
|
||||
|
||||
// "word" "kind" "extra text"
|
||||
const hlf_T hlfsNorm[3] = { HLF_PNI, HLF_PNK, HLF_PNX };
|
||||
@@ -644,8 +645,6 @@ void pum_redraw(void)
|
||||
thumb_pos = (pum_first * (pum_height - thumb_height) + scroll_range / 2) / scroll_range;
|
||||
}
|
||||
|
||||
const int ellipsis_width = 3;
|
||||
|
||||
for (int i = 0; i < pum_height; i++) {
|
||||
int idx = i + pum_first;
|
||||
const hlf_T *const hlfs = (idx == pum_selected) ? hlfsSel : hlfsNorm;
|
||||
@@ -668,7 +667,7 @@ void pum_redraw(void)
|
||||
// Do this 3 times and order from p_cia
|
||||
int grid_col = col_off;
|
||||
int totwidth = 0;
|
||||
bool need_ellipsis = false;
|
||||
bool need_fcs_trunc = false;
|
||||
int order[3];
|
||||
int items_width_array[3] = { pum_base_width, pum_kind_width, pum_extra_width };
|
||||
pum_align_order(order);
|
||||
@@ -721,9 +720,8 @@ void pum_redraw(void)
|
||||
char *rt = reverse_text(st);
|
||||
char *rt_start = rt;
|
||||
int cells = (int)mb_string2cells(rt);
|
||||
if (p_pmw > ellipsis_width && pum_width == p_pmw
|
||||
&& grid_col - cells < col_off - pum_width) {
|
||||
need_ellipsis = true;
|
||||
if (pum_width == p_pmw && totwidth + 1 + cells >= pum_width) {
|
||||
need_fcs_trunc = true;
|
||||
}
|
||||
|
||||
if (grid_col - cells < col_off - pum_width) {
|
||||
@@ -751,9 +749,8 @@ void pum_redraw(void)
|
||||
grid_col -= width;
|
||||
} else {
|
||||
int cells = (int)mb_string2cells(st);
|
||||
if (p_pmw > ellipsis_width && pum_width == p_pmw
|
||||
&& grid_col + cells > col_off + pum_width) {
|
||||
need_ellipsis = true;
|
||||
if (pum_width == p_pmw && totwidth + 1 + cells >= pum_width) {
|
||||
need_fcs_trunc = true;
|
||||
}
|
||||
|
||||
if (attrs == NULL) {
|
||||
@@ -820,21 +817,21 @@ void pum_redraw(void)
|
||||
if (pum_rl) {
|
||||
const int lcol = col_off - pum_width + 1;
|
||||
grid_line_fill(lcol, grid_col + 1, schar_from_ascii(' '), orig_attr);
|
||||
if (need_ellipsis) {
|
||||
bool over_wide = pum_width > ellipsis_width && linebuf_char[lcol + ellipsis_width] == NUL;
|
||||
grid_line_fill(lcol, lcol + ellipsis_width, schar_from_ascii('.'), orig_attr);
|
||||
if (over_wide) {
|
||||
grid_line_put_schar(lcol + ellipsis_width, schar_from_ascii(' '), orig_attr);
|
||||
if (need_fcs_trunc) {
|
||||
linebuf_char[lcol] = fcs_trunc != NUL && fcs_trunc != schar_from_ascii('>')
|
||||
? fcs_trunc : schar_from_ascii('<');
|
||||
if (pum_width > 1 && linebuf_char[lcol + 1] == NUL) {
|
||||
linebuf_char[lcol + 1] = schar_from_ascii(' ');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const int rcol = col_off + pum_width;
|
||||
grid_line_fill(grid_col, rcol, schar_from_ascii(' '), orig_attr);
|
||||
if (need_ellipsis) {
|
||||
if (pum_width > ellipsis_width && linebuf_char[rcol - ellipsis_width] == NUL) {
|
||||
grid_line_put_schar(rcol - ellipsis_width - 1, schar_from_ascii(' '), orig_attr);
|
||||
if (need_fcs_trunc) {
|
||||
if (pum_width > 1 && linebuf_char[rcol - 1] == NUL) {
|
||||
linebuf_char[rcol - 2] = schar_from_ascii(' ');
|
||||
}
|
||||
grid_line_fill(rcol - ellipsis_width, rcol, schar_from_ascii('.'), orig_attr);
|
||||
linebuf_char[rcol - 1] = fcs_trunc != NUL ? fcs_trunc : schar_from_ascii('>');
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user