aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view')
-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,
}
}