Correct prefix length calculation in completion measurement

A completion may have zero length; in this case the length of the
prefix was omitted and the completion was not visible. Correct the
calculation to account for zero-width completions.

Fixes #4424
This commit is contained in:
ridiculousfish 2017-09-23 13:06:44 -07:00
parent 0d93125664
commit 43d0016125

View file

@ -328,7 +328,7 @@ void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring &
// fish_wcswidth() can return -1 if it can't calculate the width. So be cautious.
int comp_width = fish_wcswidth(comp_strings.at(j).c_str());
if (comp_width > 0) comp->comp_width += prefix_len + comp_width;
if (comp_width >= 0) comp->comp_width += prefix_len + comp_width;
}
// fish_wcswidth() can return -1 if it can't calculate the width. So be cautious.