@@ -209,6 +209,24 @@ pub fn merge_toml_values(left: toml::Value, right: toml::Value, merge_depth: usi
212+/// Finds the current workspace folder.
213+/// Used as a ceiling dir for LSP root resolution, the filepicker and potentially as a future filewatching root
215+/// This function starts searching the FS upward from the CWD
216+/// and returns the first directory that contains either `.git` or `.helix`.
217+/// If no workspace was found returns (CWD, true).
218+/// Otherwise (workspace, false) is returned
219+pub fn find_workspace() -> (PathBuf, bool) {
220+ let current_dir = std::env::current_dir().expect("unable to determine current directory");
221+ for ancestor in current_dir.ancestors() {
222+ if ancestor.join(".git").exists() || ancestor.join(".helix").exists() {
223+ return (ancestor.to_owned(), false);
212#[cfg(test)]
230#[cfg(test)]
213mod merge_toml_tests {
231mod merge_toml_tests {
214 use std::str;
232 use std::str;
@@ -281,21 +299,3 @@ mod merge_toml_tests {
285−/// Finds the current workspace folder.
286−/// Used as a ceiling dir for LSP root resolution, the filepicker and potentially as a future filewatching root
288−/// This function starts searching the FS upward from the CWD
289−/// and returns the first directory that contains either `.git` or `.helix`.
290−/// If no workspace was found returns (CWD, true).
291−/// Otherwise (workspace, false) is returned
292−pub fn find_workspace() -> (PathBuf, bool) {
293− let current_dir = std::env::current_dir().expect("unable to determine current directory");
294− for ancestor in current_dir.ancestors() {
295− if ancestor.join(".git").exists() || ancestor.join(".helix").exists() {
296− return (ancestor.to_owned(), false);