Fix directory explore scheduling

Fixes https://github.com/sayanarijit/xplr/issues/503
pull/512/head v0.19.3
Arijit Basu 2 years ago committed by Arijit Basu
parent f2713d9549
commit 58c572d77a

2
Cargo.lock generated

@ -1203,7 +1203,7 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
[[package]]
name = "xplr"
version = "0.19.2"
version = "0.19.3"
dependencies = [
"ansi-to-tui",
"anyhow",

@ -8,7 +8,7 @@ path = './benches/criterion.rs'
[package]
name = 'xplr'
version = '0.19.2'
version = '0.19.3'
authors = ['Arijit Basu <hi@arijitbasu.in>']
edition = '2021'
description = 'A hackable, minimal, fast TUI file explorer'

@ -45,7 +45,7 @@ compatibility.
### Instructions
#### [v0.18.0][46] -> [v0.19.2][47]
#### [v0.18.0][46] -> [v0.19.3][47]
- BREAKING: The builtin modes cannot be accessed using space separated names
anymore. Use underscore separated mode names. For e.g.
@ -387,4 +387,4 @@ Else do the following:
[44]: https://github.com/sayanarijit/xplr/releases/tag/v0.16.4
[45]: https://github.com/sayanarijit/xplr/releases/tag/v0.17.6
[46]: https://github.com/sayanarijit/xplr/releases/tag/v0.18.0
[47]: https://github.com/sayanarijit/xplr/releases/tag/v0.19.2
[47]: https://github.com/sayanarijit/xplr/releases/tag/v0.19.3

@ -1109,6 +1109,15 @@ impl App {
}
pub fn set_directory(mut self, dir: DirectoryBuffer) -> Result<Self> {
if self
.directory_buffer
.as_ref()
.map(|d| d.explored_at >= dir.explored_at)
.unwrap_or(false)
{
return Ok(self);
};
self = self.add_last_focus(
dir.parent.clone(),
dir.focused_node().map(|n| n.relative_path.clone()),

@ -1,4 +1,5 @@
use crate::node::Node;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
@ -7,6 +8,9 @@ pub struct DirectoryBuffer {
pub nodes: Vec<Node>,
pub total: usize,
pub focus: usize,
#[serde(skip)]
pub explored_at: DateTime<Utc>,
}
impl DirectoryBuffer {
@ -17,6 +21,7 @@ impl DirectoryBuffer {
nodes,
total,
focus,
explored_at: Utc::now(),
}
}

@ -146,24 +146,24 @@ mod tests {
assert!(check_version(VERSION, "foo path").is_ok());
// Current release if OK
assert!(check_version("0.19.2", "foo path").is_ok());
assert!(check_version("0.19.3", "foo path").is_ok());
// Prev major release is ERR
// - Not yet
// Prev minor release is ERR (Change when we get to v1)
assert!(check_version("0.18.2", "foo path").is_err());
assert!(check_version("0.18.3", "foo path").is_err());
// Prev bugfix release is OK
assert!(check_version("0.19.1", "foo path").is_ok());
assert!(check_version("0.19.2", "foo path").is_ok());
// Next major release is ERR
assert!(check_version("1.19.2", "foo path").is_err());
assert!(check_version("1.19.3", "foo path").is_err());
// Next minor release is ERR
assert!(check_version("0.20.2", "foo path").is_err());
assert!(check_version("0.20.3", "foo path").is_err());
// Next bugfix release is ERR (Change when we get to v1)
assert!(check_version("0.19.3", "foo path").is_err());
assert!(check_version("0.19.4", "foo path").is_err());
}
}

Loading…
Cancel
Save