From 8b9b02f08b5554a4c17e533937c74c1fb80df5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Mon, 22 Feb 2021 12:06:28 +0900 Subject: [PATCH] minor --- TODO.md | 3 ++- helix-view/src/document.rs | 9 +++++---- helix-view/src/tree.rs | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 8318b0bfb..e378d4578 100644 --- a/TODO.md +++ b/TODO.md @@ -27,8 +27,9 @@ - [ ] regex search / select next - [ ] f / t mappings +- [ ] open_above (O) command - [ ] = for auto indent line/selection -- [ ] q should only close the view, if all are closed, close the editor +- [x] q should only close the view, if all are closed, close the editor - [ ] buffers should sit on editor.buffers, view simply refs them diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 426c8e21a..569e72eee 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -300,10 +300,11 @@ impl Document { } pub fn relative_path(&self) -> Option<&Path> { - self.path.as_ref().map(|path| { - path.strip_prefix(std::env::current_dir().unwrap()) - .unwrap_or(path) - }) + let cwdir = std::env::current_dir().expect("couldn't determine current directory"); + + self.path + .as_ref() + .map(|path| path.strip_prefix(cwdir).unwrap_or(path)) } // pub fn slice(&self, range: R) -> RopeSlice where R: RangeBounds { diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs index 9903ba79d..382ef09e8 100644 --- a/helix-view/src/tree.rs +++ b/helix-view/src/tree.rs @@ -303,6 +303,27 @@ impl Tree { // For now that's okay though, since it's unlikely you'll be able to open a large enough // number of splits to notice. + // current = focus + // let found = loop do { + // node = focus.parent; + // let found = node.next_sibling_of(current) + // if some { + // break found; + // } + // // else + // if node == root { + // return first child of root; + // }; + // current = parent; + // } + // } + // + // use found next sibling + // loop do { + // if found = view -> focus = found, return + // if found = container -> found = first child + // } + let iter = self.traverse(); let mut iter = iter.skip_while(|&(key, _view)| key != self.focus);