Skip to content

Commit

Permalink
Fix directory explore scheduling
Browse files Browse the repository at this point in the history
Fixes #503
  • Loading branch information
sayanarijit committed Sep 11, 2022
1 parent f2713d9 commit 58c572d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions docs/en/src/upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
5 changes: 5 additions & 0 deletions src/directory_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::node::Node;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
Expand All @@ -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 {
Expand All @@ -17,6 +21,7 @@ impl DirectoryBuffer {
nodes,
total,
focus,
explored_at: Utc::now(),
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 58c572d

Please sign in to comment.