summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--development.md2
-rw-r--r--src/mode.rs9
-rw-r--r--src/tab.rs2
3 files changed, 11 insertions, 2 deletions
diff --git a/development.md b/development.md
index ccccbeb..1492b0a 100644
--- a/development.md
+++ b/development.md
@@ -490,7 +490,7 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally.
- [x] FIX: incompatible config files between versions crashes the app.
- [x] FIX: Help string susbtitution aren't aligned properly
- [x] FIX: exiting preview doesn't refresh
-- [ ] Mode should know if a refresh is required after leaving them.
+- [x] Mode should know if a refresh is required after leaving them.
## Current dev
diff --git a/src/mode.rs b/src/mode.rs
index ac6ba7d..012f0a2 100644
--- a/src/mode.rs
+++ b/src/mode.rs
@@ -131,6 +131,15 @@ pub enum Mode {
InputSimple(InputSimple),
}
+impl Mode {
+ /// True if the mode requires a view refresh when left.
+ /// Most modes don't, since they don't display their content in the first window.
+ /// content. But `Mode::Preview` does, since it uses the main window.
+ pub fn refresh_required(&self) -> bool {
+ matches!(*self, Mode::Preview)
+ }
+}
+
impl fmt::Display for Mode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
diff --git a/src/tab.rs b/src/tab.rs
index bfdaa29..bb4fabe 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -389,7 +389,7 @@ impl Tab {
/// The last mode is set to normal again.
/// Returns True if the last mode requires a refresh afterwards.
pub fn reset_mode(&mut self) -> bool {
- let must_refresh = matches!(self.mode, Mode::Preview);
+ let must_refresh = self.mode.refresh_required();
self.mode = self.previous_mode;
self.previous_mode = Mode::Normal;
must_refresh