Skip to content

Commit

Permalink
Refactor shared buffer methods to pass only editor, not whole compositor
Browse files Browse the repository at this point in the history
  • Loading branch information
EpocSquadron committed Feb 27, 2022
1 parent 78ae600 commit d011456
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2144,9 +2144,9 @@ pub mod cmd {
buffer_close_by_ids_impl(cx.editor, document_ids, true)
}

fn buffer_gather_others_impl(cx: &mut compositor::Context) -> Vec<DocumentId> {
let current_document = &doc!(cx.editor).id();
cx.editor
fn buffer_gather_others_impl(editor: &mut Editor) -> Vec<DocumentId> {
let current_document = &doc!(editor).id();
editor
.documents()
.map(|doc| doc.id())
.filter(|doc_id| doc_id != current_document)
Expand All @@ -2158,7 +2158,7 @@ pub mod cmd {
_args: &[Cow<str>],
_event: PromptEvent,
) -> anyhow::Result<()> {
let document_ids = buffer_gather_others_impl(cx);
let document_ids = buffer_gather_others_impl(cx.editor);
buffer_close_by_ids_impl(cx.editor, document_ids, false)
}

Expand All @@ -2167,20 +2167,20 @@ pub mod cmd {
_args: &[Cow<str>],
_event: PromptEvent,
) -> anyhow::Result<()> {
let document_ids = buffer_gather_others_impl(cx);
let document_ids = buffer_gather_others_impl(cx.editor);
buffer_close_by_ids_impl(cx.editor, document_ids, true)
}

fn buffer_gather_all_impl(cx: &mut compositor::Context) -> Vec<DocumentId> {
cx.editor.documents().map(|doc| doc.id()).collect()
fn buffer_gather_all_impl(editor: &mut Editor) -> Vec<DocumentId> {
editor.documents().map(|doc| doc.id()).collect()
}

fn buffer_close_all(
cx: &mut compositor::Context,
_args: &[Cow<str>],
_event: PromptEvent,
) -> anyhow::Result<()> {
let document_ids = buffer_gather_all_impl(cx);
let document_ids = buffer_gather_all_impl(cx.editor);
buffer_close_by_ids_impl(cx.editor, document_ids, false)
}

Expand All @@ -2189,7 +2189,7 @@ pub mod cmd {
_args: &[Cow<str>],
_event: PromptEvent,
) -> anyhow::Result<()> {
let document_ids = buffer_gather_all_impl(cx);
let document_ids = buffer_gather_all_impl(cx.editor);
buffer_close_by_ids_impl(cx.editor, document_ids, true)
}

Expand Down

0 comments on commit d011456

Please sign in to comment.