From 313bee78b8b664ee8caf31a958d831e5b3e746e6 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Thu, 5 Oct 2023 21:30:31 +0800 Subject: [PATCH] .. --- app/src/app.rs | 22 ++++++++++------------ config/preset/keymap.toml | 10 +++++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/src/app.rs b/app/src/app.rs index 6a6a116a..525f5a6f 100644 --- a/app/src/app.rs +++ b/app/src/app.rs @@ -42,19 +42,17 @@ impl App { } fn dispatch_quit(&mut self, no_cwd_file: bool) { - if !no_cwd_file { - if let Some(p) = &BOOT.cwd_file { - let cwd = self.cx.manager.cwd().as_os_str(); + if let Some(p) = BOOT.cwd_file.as_ref().filter(|_| !no_cwd_file) { + let cwd = self.cx.manager.cwd().as_os_str(); - #[cfg(target_os = "windows")] - { - std::fs::write(p, cwd.to_string_lossy().as_bytes()).ok(); - } - #[cfg(not(target_os = "windows"))] - { - use std::os::unix::ffi::OsStrExt; - std::fs::write(p, cwd.as_bytes()).ok(); - } + #[cfg(target_os = "windows")] + { + std::fs::write(p, cwd.to_string_lossy().as_bytes()).ok(); + } + #[cfg(not(target_os = "windows"))] + { + use std::os::unix::ffi::OsStrExt; + std::fs::write(p, cwd.as_bytes()).ok(); } } } diff --git a/config/preset/keymap.toml b/config/preset/keymap.toml index ed9df9fb..7109c75f 100644 --- a/config/preset/keymap.toml +++ b/config/preset/keymap.toml @@ -1,11 +1,11 @@ [manager] keymap = [ - { on = [ "" ], exec = "escape", desc = "Exit visual mode, clear selected, or cancel search" }, - { on = [ "q" ], exec = "quit", desc = "Exit the process" }, - { on = [ "Q" ], exec = "quit --no-cwd-file", desc = "Exit the process without writing the current directory to cwd-file" }, - { on = [ "" ], exec = "close", desc = "Close the current tab, or quit if it is last tab" }, - { on = [ "" ], exec = "suspend", desc = "Suspend the process" }, + { on = [ "" ], exec = "escape", desc = "Exit visual mode, clear selected, or cancel search" }, + { on = [ "q" ], exec = "quit", desc = "Exit the process" }, + { on = [ "Q" ], exec = "quit --no-cwd-file", desc = "Exit the process without writing cwd-file" }, + { on = [ "" ], exec = "close", desc = "Close the current tab, or quit if it is last tab" }, + { on = [ "" ], exec = "suspend", desc = "Suspend the process" }, # Navigation { on = [ "k" ], exec = "arrow -1", desc = "Move cursor up" },