mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 21:03:12 +00:00
Fix pager being blank when token prefix contains newline
Given
$ echo {\
C
where C is the cursor.
Completions have prefix "{\\\n".
Since \n has a wcwidth of -1, this line always fails
let prefix_len = usize::try_from(fish_wcswidth(&self.prefix));
This triggers uncovers a regression in 43e2d7b48
(Port pager.cpp, 2023-12-02),
where we end up computing comp_width=0 for all completions.
Fix this. Test in the next commit.
The C++ version added the prefix width only if the completion had a valid
width. That seems wrong, let's do it always (if the prefix width is valid).
This commit is contained in:
parent
cd541575b4
commit
f5c6829670
1 changed files with 2 additions and 4 deletions
|
@ -356,10 +356,8 @@ impl Pager {
|
|||
|
||||
// fish_wcswidth() can return -1 if it can't calculate the width. So be cautious.
|
||||
let comp_width = fish_wcswidth(comp_string);
|
||||
if let (Ok(prefix_len), Ok(comp_width)) = (prefix_len, usize::try_from(comp_width))
|
||||
{
|
||||
comp.comp_width += prefix_len + comp_width;
|
||||
}
|
||||
comp.comp_width += prefix_len.unwrap_or_default();
|
||||
comp.comp_width += usize::try_from(comp_width).unwrap_or_default();
|
||||
}
|
||||
|
||||
// fish_wcswidth() can return -1 if it can't calculate the width. So be cautious.
|
||||
|
|
Loading…
Reference in a new issue