summaryrefslogtreecommitdiffstats
path: root/src/tab.rs
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-10-17 09:38:25 +0200
committerqkzk <qu3nt1n@gmail.com>2023-10-17 09:38:25 +0200
commit169b2671289beb96452d63a3c4d4feb831fba6db (patch)
treefd36275474aef61a659ff086230975f317a662d2 /src/tab.rs
parent2e1a2d2b71d9064fb1c73acf7460b3530060ea5c (diff)
Fix refresh if needed. Should work most of the times
Diffstat (limited to 'src/tab.rs')
-rw-r--r--src/tab.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tab.rs b/src/tab.rs
index d81dddf..c7bee05 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -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(())
}