Skip to content

Commit

Permalink
Move remove document code into View function 'remove_document'
Browse files Browse the repository at this point in the history
  • Loading branch information
gavynriebau committed Jun 3, 2022
1 parent 955a6cd commit edd5a38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 1 addition & 5 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
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 All @@ -826,9 +825,6 @@ impl Editor {
Some(Action::Close(view.id))
}
} else {
// documents also need be removed from the view "document access history"
// so we don't accidentally try to jump back to them after they have been deleted
view.docs_access_history.retain(|doc| doc != &doc_id);
None
}
})
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

0 comments on commit edd5a38

Please sign in to comment.