From edd5a38688e37054ca545b76c78b6d692209cc5d Mon Sep 17 00:00:00 2001 From: Gavyn Riebau Date: Fri, 3 Jun 2022 19:15:35 +0800 Subject: [PATCH] Move remove document code into View function 'remove_document' --- helix-view/src/editor.rs | 6 +----- helix-view/src/view.rs | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 1f3d57dc1ecd..8f51c2ee8ba6 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -814,8 +814,7 @@ impl Editor { .tree .views_mut() .filter_map(|(view, _focus)| { - // remove the document from jump list of all views - view.jumps.remove(&doc_id); + view.remove_document(&doc_id); if view.doc == doc_id { // something was previously open in the view, switch to previous doc @@ -826,9 +825,6 @@ impl Editor { Some(Action::Close(view.id)) } } else { - // documents also need be removed from the view "document access history" - // so we don't accidentally try to jump back to them after they have been deleted - view.docs_access_history.retain(|doc| doc != &doc_id); None } }) diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs index 091d1f2ee1c8..a496fe3306b7 100644 --- a/helix-view/src/view.rs +++ b/helix-view/src/view.rs @@ -316,6 +316,11 @@ impl View { )) } + pub fn remove_document(&mut self, doc_id: &DocumentId) { + self.jumps.remove(doc_id); + self.docs_access_history.retain(|doc| doc != doc_id); + } + // pub fn traverse(&self, text: RopeSlice, start: usize, end: usize, fun: F) // where // F: Fn(usize, usize),