terminal: fix moving selection on history changing
parent
ad755b0e3d
commit
330ce07d48
|
|
@ -493,6 +493,10 @@ pub const ScreenSearch = struct {
|
||||||
// in our history (fast path)
|
// in our history (fast path)
|
||||||
if (results.items.len == 0) break :history;
|
if (results.items.len == 0) break :history;
|
||||||
|
|
||||||
|
// The number added to our history. Needed for updating
|
||||||
|
// our selection if we have one.
|
||||||
|
const added_len = results.items.len;
|
||||||
|
|
||||||
// Matches! Reverse our list then append all the remaining
|
// Matches! Reverse our list then append all the remaining
|
||||||
// history items that didn't start on our original node.
|
// history items that didn't start on our original node.
|
||||||
std.mem.reverse(FlattenedHighlight, results.items);
|
std.mem.reverse(FlattenedHighlight, results.items);
|
||||||
|
|
@ -505,7 +509,7 @@ pub const ScreenSearch = struct {
|
||||||
if (self.selected) |*m| selected: {
|
if (self.selected) |*m| selected: {
|
||||||
const active_len = self.active_results.items.len;
|
const active_len = self.active_results.items.len;
|
||||||
if (m.idx < active_len) break :selected;
|
if (m.idx < active_len) break :selected;
|
||||||
m.idx += results.items.len;
|
m.idx += added_len;
|
||||||
|
|
||||||
// Moving the idx should not change our targeted result
|
// Moving the idx should not change our targeted result
|
||||||
// since the history is immutable.
|
// since the history is immutable.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue