This commit is contained in:
Blaž Hrastnik 2021-02-22 12:06:28 +09:00
parent 3b6c9648f3
commit 8b9b02f08b
3 changed files with 28 additions and 5 deletions

View File

@ -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

View File

@ -300,10 +300,11 @@ pub fn selection(&self) -> &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)
})
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<R>(&self, range: R) -> RopeSlice where R: RangeBounds {

View File

@ -303,6 +303,27 @@ pub fn focus_next(&mut self) {
// 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);