1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-10 15:04:32 +03:00

tidy up add_to_config_reload_watch_list

refs: #989
This commit is contained in:
Wez Furlong 2021-08-10 20:38:41 -07:00
parent e8e40c9704
commit 8cc90dcf33
2 changed files with 11 additions and 11 deletions

View File

@ -480,24 +480,23 @@ impl ConfigInner {
self.generation += 1;
let mut watch_paths = vec![];
if let Some(path) = file_name {
watch_paths.push(path);
}
// If we loaded a user config, publish this latest version of
// the lua state to the LUA_PIPE. This allows a subsequent
// call to `with_lua_config` to reference this lua context
// even though we are (probably) resolving this from a background
// reloading thread.
if let Some(lua) = lua {
ConfigInner::accumulate_watch_paths(&lua, &mut watch_paths);
// If we loaded a user config, publish this latest version of
// the lua state to the LUA_PIPE. This allows a subsequent
// call to `with_lua_config` to reference this lua context
// even though we are (probably) resolving this from a background
// reloading thread.
LUA_PIPE.sender.try_send(lua).ok();
}
log::debug!("Reloaded configuration! generation={}", self.generation);
self.notify();
if self.config.automatically_reload_config {
if watch_paths.is_empty() {
if let Some(path) = file_name {
watch_paths.push(path);
}
}
for path in watch_paths {
self.watch_path(path);
}

View File

@ -75,7 +75,6 @@ pub fn make_lua_context(config_file: &Path) -> anyhow::Result<Lua> {
.to_str()
.ok_or_else(|| anyhow!("config file path is not UTF-8"))?;
lua.set_named_registry_value("wezterm-watch-paths", vec![config_file_str])?;
wezterm_mod.set("config_file", config_file_str)?;
wezterm_mod.set(
"config_dir",
@ -83,6 +82,8 @@ pub fn make_lua_context(config_file: &Path) -> anyhow::Result<Lua> {
.to_str()
.ok_or_else(|| anyhow!("config dir path is not UTF-8"))?,
)?;
lua.set_named_registry_value("wezterm-watch-paths", Vec::<String>::new())?;
wezterm_mod.set(
"add_to_config_reload_watch_list",
lua.create_function(|lua, args: Variadic<String>| {