From b99db7c6875f74a15dcfb0cfdb3334c837d4aab1 Mon Sep 17 00:00:00 2001 From: Kirawi Date: Tue, 24 Aug 2021 21:04:05 -0400 Subject: Move path util functions from helix-term to helix-core (#650) --- helix-term/src/commands.rs | 3 +-- helix-term/src/ui/mod.rs | 2 +- helix-term/src/ui/picker.rs | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'helix-term/src') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 89855cbb..9a7b6510 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2291,8 +2291,7 @@ fn buffer_picker(cx: &mut Context) { .map(|(id, doc)| (id, doc.path().cloned())) .collect(), move |(id, path): &(DocumentId, Option)| { - use helix_view::document::relative_path; - let path = path.as_deref().map(relative_path); + let path = path.as_deref().map(helix_core::path::get_relative_path); match path.as_ref().and_then(|path| path.to_str()) { Some(path) => { if *id == current { diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 390f1a66..e4871312 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -208,7 +208,7 @@ pub mod completers { use std::path::Path; let is_tilde = input.starts_with('~') && input.len() == 1; - let path = helix_view::document::expand_tilde(Path::new(input)); + let path = helix_core::path::expand_tilde(Path::new(input)); let (dir, file_name) = if input.ends_with('/') { (path, None) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index a864ab6d..ef2c434c 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -17,7 +17,6 @@ use std::{borrow::Cow, collections::HashMap, path::PathBuf}; use crate::ui::{Prompt, PromptEvent}; use helix_core::Position; use helix_view::{ - document::canonicalize_path, editor::Action, graphics::{Color, CursorKind, Margin, Rect, Style}, Document, Editor, @@ -54,7 +53,11 @@ impl FilePicker { self.picker .selection() .and_then(|current| (self.file_fn)(editor, current)) - .and_then(|(path, line)| canonicalize_path(&path).ok().zip(Some(line))) + .and_then(|(path, line)| { + helix_core::path::get_canonicalized_path(&path) + .ok() + .zip(Some(line)) + }) } fn calculate_preview(&mut self, editor: &Editor) { -- cgit v1.2.3-70-g09d2