mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 15:04:36 +03:00
allow debug overlay to open even if the config file is busted
refs: https://github.com/wez/wezterm/issues/1174
This commit is contained in:
parent
eb50c68228
commit
d23414105e
@ -731,17 +731,7 @@ impl Config {
|
||||
std::env::remove_var("WEZTERM_CONFIG_FILE");
|
||||
std::env::remove_var("WEZTERM_CONFIG_DIR");
|
||||
|
||||
fn try_default() -> anyhow::Result<LoadedConfig> {
|
||||
let config = default_config_with_overrides_applied()?.compute_extra_defaults(None);
|
||||
|
||||
Ok(LoadedConfig {
|
||||
config: Ok(config),
|
||||
file_name: None,
|
||||
lua: Some(make_lua_context(Path::new(""))?),
|
||||
})
|
||||
}
|
||||
|
||||
match try_default() {
|
||||
match Self::try_default() {
|
||||
Err(err) => LoadedConfig {
|
||||
config: Err(err),
|
||||
file_name: None,
|
||||
@ -751,6 +741,16 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_default() -> anyhow::Result<LoadedConfig> {
|
||||
let config = default_config_with_overrides_applied()?.compute_extra_defaults(None);
|
||||
|
||||
Ok(LoadedConfig {
|
||||
config: Ok(config),
|
||||
file_name: None,
|
||||
lua: Some(make_lua_context(Path::new(""))?),
|
||||
})
|
||||
}
|
||||
|
||||
fn try_load(
|
||||
path_item: &PathPossibility,
|
||||
overrides: &wezterm_dynamic::Value,
|
||||
|
@ -130,13 +130,17 @@ impl LineEditorHost for LuaReplHost {
|
||||
pub fn show_debug_overlay(mut term: TermWizTerminal, gui_win: GuiWin) -> anyhow::Result<()> {
|
||||
term.no_grab_mouse_in_raw_mode();
|
||||
|
||||
let config::LoadedConfig {
|
||||
lua,
|
||||
config,
|
||||
file_name: _,
|
||||
} = config::Config::load();
|
||||
config?;
|
||||
let lua = lua.ok_or_else(|| anyhow::anyhow!("failed to setup lua context"))?;
|
||||
let config::LoadedConfig { lua, .. } = config::Config::load();
|
||||
// Try hard to fall back to some kind of working lua context even
|
||||
// if the user's config file is temporarily out of whack
|
||||
let lua = match lua {
|
||||
Some(lua) => lua,
|
||||
None => match config::Config::try_default() {
|
||||
Ok(config::LoadedConfig { lua: Some(lua), .. }) => lua,
|
||||
_ => config::lua::make_lua_context(std::path::Path::new(""))?,
|
||||
},
|
||||
};
|
||||
|
||||
lua.load("wezterm = require 'wezterm'").exec()?;
|
||||
lua.globals().set("window", gui_win)?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user