Skip to content

write-buffer-close-all and write-buffer-close-all! #15355

@brunomartins-rdev

Description

@brunomartins-rdev

I have not seen this posted in any issue nor PR.

I am aware of the existence of wqa and wqa!, but having wbca and wbca! actually seems like a feature worthy of implementing, as sometimes changing work from a part of a repo to another could be done without exiting the editor, but still closing all of the open buffers.

Even if it is only for the sake of consistency since we already have bca, bca!, wbc and wbc!.

I develop mostly in C and R, but can try to implement this and open a PR with some guidance from a dev who knows the codebase, but looking at helix-term/src/commands/typed.rs I assume it would look something like

fn write_buffer_close_all(
    cx: &mut compositor::Context,
    args: Args,
    event: PromptEvent,
) -> anyhow::Result<()> {
    if event != PromptEvent::Validate {
        return Ok(());
    }

    write_impl(
        cx,
        args.first(),
        WriteOptions {
            force: false,
            auto_format: !args.has_flag(WRITE_NO_FORMAT_FLAG.name),
        },
    )?;

    let document_ids = buffer_gather_all_impl(cx.editor);
    buffer_close_by_ids_impl(cx, &document_ids, false)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions