quickselect: avoid a panic when used with mux

It looks like the mux search results include a trailing newline
in some cases, which means that a match can wrap onto a second
line.

If that line is shorter than the label length, we could panic.

This commit makes quickselect safer to use in this situation,
but the real fix is with the mux search code.
This commit is contained in:
Wez Furlong committed 2021-04-26 09:58:16 -07:00
1 parent d907b86a91
commit 3ad2a46ecf
1 file changed
+5 -1
+5 -1
View File
@@ -450,7 +450,11 @@ impl Pane for QuickSelectOverlay {
}
}
for (idx, c) in m.label.chars().enumerate() {
let mut attr = line.cells()[idx].attrs().clone();
let mut attr = line
.cells()
.get(idx)
.map(|cell| cell.attrs().clone())
.unwrap_or_else(|| CellAttributes::default());
attr.set_background(AnsiColor::Fuschia)
.set_foreground(AnsiColor::Black)
.set_reverse(false);