@@ -17,6 +17,9 @@ mod state;
17pub mod syntax;
17pub mod syntax;
18mod transaction;
18mod transaction;
20+static RUNTIME_DIR: once_cell::sync::Lazy<std::path::PathBuf> =
21+ once_cell::sync::Lazy::new(runtime_dir);
20pub fn find_first_non_whitespace_char(line: RopeSlice) -> Option<usize> {
23pub fn find_first_non_whitespace_char(line: RopeSlice) -> Option<usize> {
21 line.chars().position(|ch| !ch.is_whitespace())
24 line.chars().position(|ch| !ch.is_whitespace())
@@ -47,15 +50,26 @@ pub fn find_root(root: Option<&str>) -> Option<std::path::PathBuf> {
48#[cfg(not(embed_runtime))]
51#[cfg(not(embed_runtime))]
49pub fn runtime_dir() -> std::path::PathBuf {
52pub fn runtime_dir() -> std::path::PathBuf {
50− // runtime env var || dir where binary is located
51− std::env::var("HELIX_RUNTIME")
53+ if let Ok(dir) = std::env::var("HELIX_RUNTIME") {
52− .map(|path| path.into())
54+ return dir.into();
53− .unwrap_or_else(|_| {
55+ }
57+ const RT_DIR: &str = "runtime";
58+ let conf_dir = config_dir().join(RT_DIR);
59+ if conf_dir.exists() {
63+ if let Ok(dir) = std::env::var("CARGO_MANIFEST_DIR") {
64+ // this is the directory of the crate being run by cargo, we need the workspace path so we take the parent
65+ return std::path::PathBuf::from(dir).parent().unwrap().join(RT_DIR);
68+ // fallback to location of the executable being run
54− std::env::current_exe()
69+ std::env::current_exe()
56− .and_then(|path| path.parent().map(|path| path.to_path_buf()))
71+ .and_then(|path| path.parent().map(|path| path.to_path_buf()))
57− .unwrap()
72+ .unwrap()
61pub fn config_dir() -> std::path::PathBuf {
75pub fn config_dir() -> std::path::PathBuf {