mirror of
https://github.com/helix-editor/helix.git
synced 2025-04-02 02:17:44 +03:00
editor: Remove closed Document after updating Views
When closing a document we must wait until all views have been updated first - either replacing their current document or closing the view - before we remove the document from the `documents` map. The `Editor::_refresh` helper is called by `Editor::close`. It accesses each View's Document to sync changes and ensure that the cursor is in view. When closing multiple Views at once, `Editor::_refresh` will attempt to access the closing Document while refreshing a to-be-closed View.
This commit is contained in:
parent
fb815e2c6f
commit
e148d8b311
1 changed files with 2 additions and 1 deletions
|
@ -1816,7 +1816,6 @@ impl Editor {
|
|||
if !force && doc.is_modified() {
|
||||
return Err(CloseError::BufferModified(doc.display_name().into_owned()));
|
||||
}
|
||||
let doc = self.documents.remove(&doc_id).unwrap();
|
||||
|
||||
// This will also disallow any follow-up writes
|
||||
self.saves.remove(&doc_id);
|
||||
|
@ -1857,6 +1856,8 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
let doc = self.documents.remove(&doc_id).unwrap();
|
||||
|
||||
// If the document we removed was visible in all views, we will have no more views. We don't
|
||||
// want to close the editor just for a simple buffer close, so we need to create a new view
|
||||
// containing either an existing document, or a brand new document.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue