Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic on close last buffer (#2367) #2658

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ impl Editor {

// Remove the scratch buffer from any jumplists
for (view, _) in self.tree.views_mut() {
view.jumps.remove(&id)
view.remove_document(&id);
}
} else {
let jump = (view.doc, doc.selection(view.id).clone());
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions helix-view/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down