From 5086b4d60a22b917ad4633eeb19b62178b9c86c3 Mon Sep 17 00:00:00 2001 From: Yutaka Kamei Date: Mon, 12 Jul 2021 20:56:57 +0900 Subject: [PATCH] [fix] Change selection when the resize event happens (#128) If the `selection` remains when the resize event happens, selected cursor sometimes disappears. This patch tries to keep the selection within the window. --- src/cli.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cli.rs b/src/cli.rs index 010d0c6c..a4818d4b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -96,6 +96,11 @@ pub fn entrypoint(args: ArgsOs, stdout: &mut impl Write) -> Result<()> { } else if let Event::Resize(c, r) = ev { columns = c; rows = r; + selection = if selection > r { + paths_rows(r) - 1 + } else { + selection + }; paths = find_paths(&starting_point, &query, paths_rows(rows))?; state = State::PathsChanged; }