on master help sign in
Port over Doc::relative_path.
0b63e83Blaž Hrastnik
helix-term/src/ui/editor.rs+1−1
@@ -226,7 +226,7 @@ impl EditorView {
226 );
226 );
227 surface.set_string(1, viewport.y, mode, text_color);
227 surface.set_string(1, viewport.y, mode, text_color);
228
228
229− if let Some(path) = view.doc.path() {
229+ if let Some(path) = view.doc.relative_path() {
230 surface.set_string(6, viewport.y, path.to_string_lossy(), text_color);
230 surface.set_string(6, viewport.y, path.to_string_lossy(), text_color);
231 }
231 }
232
232
helix-view/src/document.rs+8−1
@@ -1,6 +1,6 @@
1use anyhow::Error;
1use anyhow::Error;
2use std::future::Future;
2use std::future::Future;
3−use std::path::PathBuf;
3+use std::path::{Path, PathBuf};
4
4
5use helix_core::{
5use helix_core::{
6 syntax::LOADER, ChangeSet, Diagnostic, History, Position, Range, Rope, RopeSlice, Selection,
6 syntax::LOADER, ChangeSet, Diagnostic, History, Position, Range, Rope, RopeSlice, Selection,
@@ -201,6 +201,13 @@ impl Document {
201 &self.state.selection
201 &self.state.selection
202 }
202 }
203
203
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+
204 // pub fn slice<R>(&self, range: R) -> RopeSlice where R: RangeBounds {
211 // pub fn slice<R>(&self, range: R) -> RopeSlice where R: RangeBounds {
205 // self.state.doc.slice
212 // self.state.doc.slice
206 // }
213 // }