on master help sign in
Port over Doc::relative_path.
commit0b63e838e0ffe9a36a2cb51790f464d634b843af authorBlaž Hrastnik <blaz@mxxn.io> dateFri 18 Dec 2020, 17:18 (6 years ago) parent8b263ef
2 files changed+9−2
helix-term/src/ui/editor.rs+1−1 helix-view/src/document.rs+8−1
helix-term/src/ui/editor.rs+1−1
@@ -226,7 +226,7 @@ impl EditorView {
226226 );
227227 surface.set_string(1, viewport.y, mode, text_color);
228228
229− if let Some(path) = view.doc.path() {
229+ if let Some(path) = view.doc.relative_path() {
230230 surface.set_string(6, viewport.y, path.to_string_lossy(), text_color);
231231 }
232232
helix-view/src/document.rs+8−1
@@ -1,6 +1,6 @@
11use anyhow::Error;
22use std::future::Future;
3−use std::path::PathBuf;
3+use std::path::{Path, PathBuf};
44
55use helix_core::{
66 syntax::LOADER, ChangeSet, Diagnostic, History, Position, Range, Rope, RopeSlice, Selection,
@@ -201,6 +201,13 @@ impl Document {
201201 &self.state.selection
202202 }
203203
204+ pub fn relative_path(&self) -> Option<&Path> {
205+ self.path.as_ref().map(|path| {
206+ path.strip_prefix(std::env::current_dir().unwrap())
207+ .unwrap_or(path)
208+ })
209+ }
210+
204211 // pub fn slice<R>(&self, range: R) -> RopeSlice where R: RangeBounds {
205212 // self.state.doc.slice
206213 // }