summaryrefslogtreecommitdiff
path: root/helix-view/src/view.rs
diff options
context:
space:
mode:
authorgavynriebau2022-06-05 02:27:41 +0000
committerGitHub2022-06-05 02:27:41 +0000
commit026241cf72df9a684ec889a146bead9266dba374 (patch)
tree865b7fc06e60b33de95df4c6ccce90ece069946e /helix-view/src/view.rs
parent5b4e0a304bc85b55202c895622b5cccf930a171f (diff)
Fix panic on close last buffer (#2367) (#2658)
* Fix panic on close last buffer (#2367) In certain circumstances it was possible to cause a panic when closing buffers due to some mishandling of view document history. A change has been made to delete removed documents from the history of accessed documents for each view. The ensures we don't attempt to jump to a deleted document by mistake. * Move remove document code into View function 'remove_document' * Replace 'view.jumps.remove' call with 'view.remove_document' call
Diffstat (limited to 'helix-view/src/view.rs')
-rw-r--r--helix-view/src/view.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index 091d1f2e..a496fe33 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<F>(&self, text: RopeSlice, start: usize, end: usize, fun: F)
// where
// F: Fn(usize, usize),