mirror of
https://github.com/wezterm/wezterm.git
synced 2026-08-02 18:22:24 +08:00
persist charselect, repl history and others in data dir
We were using the runtime dir with a fallback to a directory that was equivalent to the data dir on !xdg systems. That meant that the state in the runtime dir was often scrubbed around a reboot. refs: https://github.com/wez/wezterm/discussions/4019 refs: https://github.com/wez/wezterm/issues/4047
This commit is contained in:
parent
3e3df823e4
commit
a07ab883af
@ -1643,6 +1643,14 @@ fn default_font_size() -> f64 {
|
||||
12.0
|
||||
}
|
||||
|
||||
pub(crate) fn compute_data_dir() -> anyhow::Result<PathBuf> {
|
||||
if let Some(runtime) = dirs_next::data_dir() {
|
||||
return Ok(runtime.join("wezterm"));
|
||||
}
|
||||
|
||||
Ok(crate::HOME_DIR.join(".local/share/wezterm"))
|
||||
}
|
||||
|
||||
pub(crate) fn compute_runtime_dir() -> anyhow::Result<PathBuf> {
|
||||
if let Some(runtime) = dirs_next::runtime_dir() {
|
||||
return Ok(runtime.join("wezterm"));
|
||||
|
||||
@ -65,6 +65,7 @@ lazy_static! {
|
||||
pub static ref HOME_DIR: PathBuf = dirs_next::home_dir().expect("can't find HOME dir");
|
||||
pub static ref CONFIG_DIRS: Vec<PathBuf> = config_dirs();
|
||||
pub static ref RUNTIME_DIR: PathBuf = compute_runtime_dir().unwrap();
|
||||
pub static ref DATA_DIR: PathBuf = compute_data_dir().unwrap();
|
||||
static ref CONFIG: Configuration = Configuration::new();
|
||||
static ref CONFIG_FILE_OVERRIDE: Mutex<Option<PathBuf>> = Mutex::new(None);
|
||||
static ref CONFIG_SKIP: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
@ -233,7 +233,7 @@ pub fn make_lua_context(config_file: &Path) -> anyhow::Result<Lua> {
|
||||
}
|
||||
path_array.insert(
|
||||
2,
|
||||
format!("{}/plugins/?/plugin/init.lua", crate::RUNTIME_DIR.display()),
|
||||
format!("{}/plugins/?/plugin/init.lua", crate::DATA_DIR.display()),
|
||||
);
|
||||
|
||||
if let Ok(exe) = std::env::current_exe() {
|
||||
|
||||
@ -68,6 +68,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* Windows: couldn't use shifted keys like `(` in the Debug Overlay. #3999
|
||||
* X11: fd leak on each call to
|
||||
[wezterm.gui.enumerate_gpus](config/lua/wezterm.gui/enumerate_gpus.md). #3612
|
||||
* Charselect and repl recency/history were not persisted across restarts. #4047 ?4019
|
||||
|
||||
### 20230712-072601-f4abf8fd
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ impl RepoSpec {
|
||||
}
|
||||
|
||||
fn plugins_dir() -> PathBuf {
|
||||
config::RUNTIME_DIR.join("plugins")
|
||||
config::DATA_DIR.join("plugins")
|
||||
}
|
||||
|
||||
fn checkout_path(&self) -> PathBuf {
|
||||
|
||||
@ -25,7 +25,7 @@ struct LuaReplHost {
|
||||
}
|
||||
|
||||
fn history_file_name() -> PathBuf {
|
||||
config::RUNTIME_DIR.join("repl-history")
|
||||
config::DATA_DIR.join("repl-history")
|
||||
}
|
||||
|
||||
impl LuaReplHost {
|
||||
|
||||
@ -95,7 +95,7 @@ struct Recent {
|
||||
}
|
||||
|
||||
fn recent_file_name() -> PathBuf {
|
||||
config::RUNTIME_DIR.join("recent-emoji.json")
|
||||
config::DATA_DIR.join("recent-emoji.json")
|
||||
}
|
||||
|
||||
fn load_recents() -> anyhow::Result<Vec<Recent>> {
|
||||
|
||||
@ -48,7 +48,7 @@ struct Recent {
|
||||
}
|
||||
|
||||
fn recent_file_name() -> PathBuf {
|
||||
config::RUNTIME_DIR.join("recent-commands.json")
|
||||
config::DATA_DIR.join("recent-commands.json")
|
||||
}
|
||||
|
||||
fn load_recents() -> anyhow::Result<Vec<Recent>> {
|
||||
|
||||
@ -265,7 +265,7 @@ pub fn load_last_release_info_and_set_banner() {
|
||||
return;
|
||||
}
|
||||
|
||||
let update_file_name = config::RUNTIME_DIR.join("check_update");
|
||||
let update_file_name = config::DATA_DIR.join("check_update");
|
||||
if let Ok(data) = std::fs::read(update_file_name) {
|
||||
let latest: Release = match serde_json::from_slice(&data) {
|
||||
Ok(d) => d,
|
||||
@ -351,7 +351,7 @@ fn update_checker() {
|
||||
|
||||
let force_ui = std::env::var_os("WEZTERM_ALWAYS_SHOW_UPDATE_UI").is_some();
|
||||
|
||||
let update_file_name = config::RUNTIME_DIR.join("check_update");
|
||||
let update_file_name = config::DATA_DIR.join("check_update");
|
||||
let delay = update_file_name
|
||||
.metadata()
|
||||
.and_then(|metadata| metadata.modified())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user