aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorRobin2021-06-12 12:21:06 +0000
committerGitHub2021-06-12 12:21:06 +0000
commit44cc0d8eb0743101724fca8787217a9d0aa01bd4 (patch)
tree388d4b85779f3ebb6e8c8489b563bd05237720f5 /helix-view/src
parent19535888735a97e0a9ccb057ea12f8bbd4dfaa7a (diff)
add alternate file (#223)
* add alternate file inspired by vim ctrl-6/kak ga commands. the alternate file is kept per view * apply feedback from #223 * rename to last_accessed * add ga doc * add fail message for ga
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/editor.rs7
-rw-r--r--helix-view/src/view.rs3
2 files changed, 10 insertions, 0 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index bd53c53b..ef0d8213 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -88,6 +88,12 @@ impl Editor {
pub fn switch(&mut self, id: DocumentId, action: Action) {
use crate::tree::Layout;
use helix_core::Selection;
+
+ if !self.documents.contains_key(id) {
+ log::error!("cannot switch to document that does not exist (anymore)");
+ return;
+ }
+
match action {
Action::Replace => {
let view = self.view();
@@ -98,6 +104,7 @@ impl Editor {
let view = self.view_mut();
view.jumps.push(jump);
+ view.last_accessed_doc = Some(view.doc);
view.doc = id;
view.first_line = 0;
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index 5d2d27fd..c0a72c78 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -67,6 +67,8 @@ pub struct View {
pub first_col: usize,
pub area: Rect,
pub jumps: JumpList,
+ /// the last accessed file before the current one
+ pub last_accessed_doc: Option<DocumentId>,
}
impl View {
@@ -78,6 +80,7 @@ impl View {
first_col: 0,
area: Rect::default(), // will get calculated upon inserting into tree
jumps: JumpList::new((doc, Selection::point(0))), // TODO: use actual sel
+ last_accessed_doc: None,
}
}