Switch document list to use indexmap::IndexMap (added dependency)

pull/11790/head
emilylime 2 months ago
parent 73deabaa40
commit 8e41e19890

1
Cargo.lock generated

@ -1433,6 +1433,7 @@ dependencies = [
"helix-stdx",
"helix-tui",
"helix-vcs",
"indexmap",
"libc",
"log",
"once_cell",

@ -51,6 +51,7 @@ log = "~0.4"
parking_lot = "0.12.3"
thiserror.workspace = true
indexmap = "2.5.0"
[target.'cfg(windows)'.dependencies]
clipboard-win = { version = "5.4", features = ["std"] }

@ -18,6 +18,7 @@ use helix_vcs::DiffProviderRegistry;
use futures_util::stream::select_all::SelectAll;
use futures_util::{future, StreamExt};
use helix_lsp::{Call, LanguageServerId};
use indexmap::IndexMap;
use tokio_stream::wrappers::UnboundedReceiverStream;
use std::{
@ -1015,7 +1016,7 @@ pub struct Editor {
pub mode: Mode,
pub tree: Tree,
pub next_document_id: DocumentId,
pub documents: BTreeMap<DocumentId, Document>,
pub documents: IndexMap<DocumentId, Document>,
// We Flatten<> to resolve the inner DocumentSavedEventFuture. For that we need a stream of streams, hence the Once<>.
// https://stackoverflow.com/a/66875668
@ -1164,7 +1165,7 @@ impl Editor {
mode: Mode::Normal,
tree: Tree::new(area),
next_document_id: DocumentId::default(),
documents: BTreeMap::new(),
documents: IndexMap::new(),
saves: HashMap::new(),
save_queue: SelectAll::new(),
write_count: 0,
@ -1595,7 +1596,7 @@ impl Editor {
// Copy `doc.id` into a variable before calling `self.documents.remove`, which requires a mutable
// borrow, invalidating direct access to `doc.id`.
let id = doc.id;
self.documents.remove(&id);
self.documents.shift_remove(&id);
// Remove the scratch buffer from any jumplists
for (view, _) in self.tree.views_mut() {
@ -1796,7 +1797,7 @@ impl Editor {
}
}
self.documents.remove(&doc_id);
self.documents.shift_remove(&doc_id);
// 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

Loading…
Cancel
Save