aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-06-07 12:32:01 +0000
committerBlaž Hrastnik2021-06-07 12:32:01 +0000
commit8d6fad4cac65083a0b08e49391c579ec793bc8f3 (patch)
tree80c2f9dd475e6d141d7828a1b7224cd316a7bc82 /helix-term/src/commands.rs
parent14830e75ff9316f8a5a428a06f3b3c8c4706d35a (diff)
lsp: Provide workspace root on client.initialize()
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs26
1 files changed, 1 insertions, 25 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index fe334117..15fac7ad 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1,5 +1,5 @@
use helix_core::{
- comment, coords_at_pos, graphemes, indent, match_brackets,
+ comment, coords_at_pos, find_root, graphemes, indent, match_brackets,
movement::{self, Direction},
object, pos_at_coords,
regex::{self, Regex},
@@ -1093,30 +1093,6 @@ pub fn command_mode(cx: &mut Context) {
cx.push_layer(Box::new(prompt));
}
-fn find_root(root: Option<&str>) -> Option<PathBuf> {
- let current_dir = std::env::current_dir().expect("unable to determine current directory");
-
- let root = match root {
- Some(root) => {
- let root = Path::new(root);
- if root.is_absolute() {
- root.to_path_buf()
- } else {
- current_dir.join(root)
- }
- }
- None => current_dir,
- };
-
- for ancestor in root.ancestors() {
- // TODO: also use defined roots if git isn't found
- if ancestor.join(".git").is_dir() {
- return Some(ancestor.to_path_buf());
- }
- }
- None
-}
-
pub fn file_picker(cx: &mut Context) {
let root = find_root(None).unwrap_or_else(|| PathBuf::from("./"));
let picker = ui::file_picker(root);