mirror of
https://github.com/helix-editor/helix.git
synced 2025-01-19 13:37:06 +04:00
* 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
This commit is contained in:
parent
5b4e0a304b
commit
026241cf72
@ -681,7 +681,7 @@ pub fn switch(&mut self, id: DocumentId, action: Action) {
|
|||||||
|
|
||||||
// Remove the scratch buffer from any jumplists
|
// Remove the scratch buffer from any jumplists
|
||||||
for (view, _) in self.tree.views_mut() {
|
for (view, _) in self.tree.views_mut() {
|
||||||
view.jumps.remove(&id)
|
view.remove_document(&id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let jump = (view.doc, doc.selection(view.id).clone());
|
let jump = (view.doc, doc.selection(view.id).clone());
|
||||||
@ -814,8 +814,7 @@ enum Action {
|
|||||||
.tree
|
.tree
|
||||||
.views_mut()
|
.views_mut()
|
||||||
.filter_map(|(view, _focus)| {
|
.filter_map(|(view, _focus)| {
|
||||||
// remove the document from jump list of all views
|
view.remove_document(&doc_id);
|
||||||
view.jumps.remove(&doc_id);
|
|
||||||
|
|
||||||
if view.doc == doc_id {
|
if view.doc == doc_id {
|
||||||
// something was previously open in the view, switch to previous doc
|
// something was previously open in the view, switch to previous doc
|
||||||
|
@ -316,6 +316,11 @@ pub fn gutter_coords_at_screen_coords(&self, row: u16, column: u16) -> Option<Po
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
// pub fn traverse<F>(&self, text: RopeSlice, start: usize, end: usize, fun: F)
|
||||||
// where
|
// where
|
||||||
// F: Fn(usize, usize),
|
// F: Fn(usize, usize),
|
||||||
|
Loading…
Reference in New Issue
Block a user