diff options
author | qkzk <qu3nt1n@gmail.com> | 2023-10-17 09:38:25 +0200 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2023-10-17 09:38:25 +0200 |
commit | 169b2671289beb96452d63a3c4d4feb831fba6db (patch) | |
tree | fd36275474aef61a659ff086230975f317a662d2 /src/tab.rs | |
parent | 2e1a2d2b71d9064fb1c73acf7460b3530060ea5c (diff) |
Fix refresh if needed. Should work most of the times
Diffstat (limited to 'src/tab.rs')
-rw-r--r-- | src/tab.rs | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -146,11 +146,18 @@ impl Tab { Ok(()) } + /// Refresh the view if files were modified in current directory. + /// If a refresh occurs, tries to select the same file as before. + /// If it can't, the first file (`.`) is selected. + /// Does nothing otherwise pub fn refresh_if_needed(&mut self) -> Result<()> { if self.path_content.path.metadata()?.modified()?.elapsed()? < std::time::Duration::new(10, 0) { + let selected_path = self.selected().context("no selected file")?.path.clone(); self.refresh_view()?; + let index = self.path_content.select_file(&selected_path); + self.scroll_to(index); } Ok(()) } |