@@ -209,6 +209,24 @@ pub fn merge_toml_values(left: toml::Value, right: toml::Value, merge_depth: usi
209209 }
210210}
211211
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
214+///
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);
224+ }
225+ }
226+
227+ (current_dir, true)
228+}
229+
212230#[cfg(test)]
213231mod merge_toml_tests {
214232 use std::str;
@@ -281,21 +299,3 @@ mod merge_toml_tests {
281299 )
282300 }
283301}
284−
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
287−///
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);
297− }
298− }
299−
300− (current_dir, true)
301−}