fix: verify if workdir exists or use homedir

This prevents alacritty from panicking if the workspace opened doesn't
exist anymore since lapce handles non-existent workspaces pretty well
This commit is contained in:
Jakub Panek 2022-06-28 19:54:38 +00:00 committed by GitHub
parent fe4e684821
commit 971bd54a59
1 changed files with 5 additions and 1 deletions

View File

@ -52,7 +52,11 @@ pub fn new(
let poll = mio::Poll::new().unwrap();
let mut config = TermConfig::default();
config.pty_config.working_directory =
cwd.or_else(|| BaseDirs::new().map(|d| PathBuf::from(d.home_dir())));
if cwd.is_some() && cwd.clone().unwrap().exists() {
cwd
} else {
BaseDirs::new().map(|d| PathBuf::from(d.home_dir()))
};
let shell = shell.trim();
if !shell.is_empty() {
let mut parts = shell.split(' ');