mirror of
https://github.com/helix-editor/helix.git
synced 2024-12-18 22:11:55 +04:00
feat: :cd
with no args changes to home directory (#12042)
This commit is contained in:
parent
5bdf14110f
commit
565bfbba25
@ -9,6 +9,7 @@
|
|||||||
use helix_core::fuzzy::fuzzy_match;
|
use helix_core::fuzzy::fuzzy_match;
|
||||||
use helix_core::indent::MAX_INDENT;
|
use helix_core::indent::MAX_INDENT;
|
||||||
use helix_core::{line_ending, shellwords::Shellwords};
|
use helix_core::{line_ending, shellwords::Shellwords};
|
||||||
|
use helix_stdx::path::home_dir;
|
||||||
use helix_view::document::{read_to_string, DEFAULT_LANGUAGE_NAME};
|
use helix_view::document::{read_to_string, DEFAULT_LANGUAGE_NAME};
|
||||||
use helix_view::editor::{CloseError, ConfigEvent};
|
use helix_view::editor::{CloseError, ConfigEvent};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
@ -1089,11 +1090,14 @@ fn change_current_directory(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let dir = args
|
let dir = match args.first() {
|
||||||
.first()
|
Some(input_path) => {
|
||||||
.context("target directory not provided")?
|
helix_stdx::path::expand_tilde(Path::new(input_path.as_ref()).to_owned())
|
||||||
.as_ref();
|
.deref()
|
||||||
let dir = helix_stdx::path::expand_tilde(Path::new(dir));
|
.to_path_buf()
|
||||||
|
}
|
||||||
|
None => home_dir()?.as_path().to_owned(),
|
||||||
|
};
|
||||||
|
|
||||||
helix_stdx::env::set_current_working_dir(dir)?;
|
helix_stdx::env::set_current_working_dir(dir)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user