on master help sign in
fix: Remove empty scratch buffer from jumplists when removing it
5ed6223Blaž Hrastnik
helix-view/src/editor.rs+7−1
@@ -671,11 +671,18 @@ impl Editor {
671 .any(|(_, v)| v.doc == doc.id && v.id != view.id);
671 .any(|(_, v)| v.doc == doc.id && v.id != view.id);
672
672
673 let (view, doc) = current!(self);
673 let (view, doc) = current!(self);
674+ let view_id = view.id;
675+
674 if remove_empty_scratch {
676 if remove_empty_scratch {
675 // Copy `doc.id` into a variable before calling `self.documents.remove`, which requires a mutable
677 // Copy `doc.id` into a variable before calling `self.documents.remove`, which requires a mutable
676 // borrow, invalidating direct access to `doc.id`.
678 // borrow, invalidating direct access to `doc.id`.
677 let id = doc.id;
679 let id = doc.id;
678 self.documents.remove(&id);
680 self.documents.remove(&id);
681+
682+ // Remove the scratch buffer from any jumplists
683+ for (view, _) in self.tree.views_mut() {
684+ view.jumps.remove(&id)
685+ }
679 } else {
686 } else {
680 let jump = (view.doc, doc.selection(view.id).clone());
687 let jump = (view.doc, doc.selection(view.id).clone());
681 view.jumps.push(jump);
688 view.jumps.push(jump);
@@ -691,7 +698,6 @@ impl Editor {
691 }
698 }
692 }
699 }
693
700
694− let view_id = view.id;
695 self.replace_document_in_view(view_id, id);
701 self.replace_document_in_view(view_id, id);
696
702
697 return;
703 return;