From 5ed622399026754b3712db7ac8c2d6fc372d0238 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Mon, 30 May 2022 01:21:41 +0900 Subject: fix: Remove empty scratch buffer from jumplists when removing it Fixes #1238 --- helix-view/src/editor.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 3ba6fea8..c53fcc7f 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -671,11 +671,18 @@ impl Editor { .any(|(_, v)| v.doc == doc.id && v.id != view.id); let (view, doc) = current!(self); + let view_id = view.id; + if remove_empty_scratch { // Copy `doc.id` into a variable before calling `self.documents.remove`, which requires a mutable // borrow, invalidating direct access to `doc.id`. let id = doc.id; self.documents.remove(&id); + + // Remove the scratch buffer from any jumplists + for (view, _) in self.tree.views_mut() { + view.jumps.remove(&id) + } } else { let jump = (view.doc, doc.selection(view.id).clone()); view.jumps.push(jump); @@ -691,7 +698,6 @@ impl Editor { } } - let view_id = view.id; self.replace_document_in_view(view_id, id); return; -- cgit v1.2.3-70-g09d2