aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-12-18 08:18:11 +0000
committerBlaž Hrastnik2020-12-18 08:18:11 +0000
commit0b63e838e0ffe9a36a2cb51790f464d634b843af (patch)
treeedf96947ab44f5fbc791c9a6d8416876ff4535cb /helix-view/src
parent8b263ef04b8a1399727c41b4e2f4017fc0be9316 (diff)
Port over Doc::relative_path.
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/document.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 7c4596ad..323c7bff 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -1,6 +1,6 @@
use anyhow::Error;
use std::future::Future;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use helix_core::{
syntax::LOADER, ChangeSet, Diagnostic, History, Position, Range, Rope, RopeSlice, Selection,
@@ -201,6 +201,13 @@ impl Document {
&self.state.selection
}
+ pub fn relative_path(&self) -> Option<&Path> {
+ self.path.as_ref().map(|path| {
+ path.strip_prefix(std::env::current_dir().unwrap())
+ .unwrap_or(path)
+ })
+ }
+
// pub fn slice<R>(&self, range: R) -> RopeSlice where R: RangeBounds {
// self.state.doc.slice
// }