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

Implement bulk buffer closing commands #1677

Merged
Prev Previous commit
Switch signature of bulk buffer closing to use slice of DocumentIds
Addresses feedback that accepting an IntoIterator implementor is too
much for an internal. Also possibly saves some moving?
  • Loading branch information
EpocSquadron committed Feb 27, 2022
commit 9a94e1d0880d044e2000932726d3147411b8f72d
16 changes: 8 additions & 8 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2079,10 +2079,10 @@ pub mod cmd {

fn buffer_close_by_ids_impl(
editor: &mut Editor,
doc_ids: impl IntoIterator<Item = DocumentId>,
doc_ids: &[DocumentId],
force: bool,
) -> anyhow::Result<()> {
for doc_id in doc_ids {
for &doc_id in doc_ids {
editor.close_document(doc_id, force)?;
}

Expand Down Expand Up @@ -2132,7 +2132,7 @@ pub mod cmd {
_event: PromptEvent,
) -> anyhow::Result<()> {
let document_ids = buffer_gather_paths_impl(cx.editor, args);
buffer_close_by_ids_impl(cx.editor, document_ids, false)
buffer_close_by_ids_impl(cx.editor, &document_ids, false)
}

fn force_buffer_close(
Expand All @@ -2141,7 +2141,7 @@ pub mod cmd {
_event: PromptEvent,
) -> anyhow::Result<()> {
let document_ids = buffer_gather_paths_impl(cx.editor, args);
buffer_close_by_ids_impl(cx.editor, document_ids, true)
buffer_close_by_ids_impl(cx.editor, &document_ids, true)
}

fn buffer_gather_others_impl(editor: &mut Editor) -> Vec<DocumentId> {
Expand All @@ -2159,7 +2159,7 @@ pub mod cmd {
_event: PromptEvent,
) -> anyhow::Result<()> {
let document_ids = buffer_gather_others_impl(cx.editor);
buffer_close_by_ids_impl(cx.editor, document_ids, false)
buffer_close_by_ids_impl(cx.editor, &document_ids, false)
}

fn force_buffer_close_others(
Expand All @@ -2168,7 +2168,7 @@ pub mod cmd {
_event: PromptEvent,
) -> anyhow::Result<()> {
let document_ids = buffer_gather_others_impl(cx.editor);
buffer_close_by_ids_impl(cx.editor, document_ids, true)
buffer_close_by_ids_impl(cx.editor, &document_ids, true)
}

fn buffer_gather_all_impl(editor: &mut Editor) -> Vec<DocumentId> {
Expand All @@ -2181,7 +2181,7 @@ pub mod cmd {
_event: PromptEvent,
) -> anyhow::Result<()> {
let document_ids = buffer_gather_all_impl(cx.editor);
buffer_close_by_ids_impl(cx.editor, document_ids, false)
buffer_close_by_ids_impl(cx.editor, &document_ids, false)
}

fn force_buffer_close_all(
Expand All @@ -2190,7 +2190,7 @@ pub mod cmd {
_event: PromptEvent,
) -> anyhow::Result<()> {
let document_ids = buffer_gather_all_impl(cx.editor);
buffer_close_by_ids_impl(cx.editor, document_ids, true)
buffer_close_by_ids_impl(cx.editor, &document_ids, true)
}

fn write_impl(cx: &mut compositor::Context, path: Option<&Cow<str>>) -> anyhow::Result<()> {
Expand Down