Skip to content

feat(commands): add vim-style shell range filters - #340

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/ex-shell-filters
Aug 24, 2026
Merged

fcoury-oai merged 1 commit into
mainfrom
fcoury/ex-shell-filters

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Why

#338 added standalone :! shell execution, but common Vim workflows still could not send buffer text to an external formatter, sort a visual selection, or replace a specific line range with command output.

What Changed

  • Support whole-buffer :%!command, numeric :2,5!command, and last-Visual :'<,'>!command filters while preserving existing shell expansion and previous-command history.
  • Pipe the exact selected text to the asynchronous shell process and spool complete raw stdout separately from bounded, sanitized Messages diagnostics.
  • Apply successful UTF-8 output as one revision-checked undo transaction, preserving line endings, marks, LSP notifications, the active buffer, and detached-session continuity.
  • Leave original text untouched when a command fails, is cancelled, produces invalid UTF-8, or finishes after its target buffer changes or closes.
  • Keep shell actions redacted from logs and unavailable to serialized configuration, agents, plugins, and :bufdo; update compatibility and detach documentation.

How to Test

  1. Open a file containing unsorted lines, run :%!sort, and confirm the entire buffer is sorted. Press u and Ctrl-r to verify the filter is one undoable change.

  2. Select several lines with characterwise, linewise, or blockwise Visual mode; press : and enter !sort. Confirm only the prefilled '<,'> range changes. Also verify a numeric range such as :2,4!sort.

  3. Run :%!sh -c 'cat; printf rejected >&2; exit 7' and confirm the buffer is unchanged while :messages reports the failure. Run :%!sleep 30 and press Ctrl-c in Messages to verify cancellation also preserves the buffer.

  4. Run the focused regression tests:

    cargo test --test editing shell_filter
    cargo test --test detach shell_filter_applies_to_its_buffer_after_client_disconnects

@fcoury
fcoury force-pushed the fcoury/ex-shell-filters branch from cb911d2 to b9afb1a Compare August 24, 2026 16:19
@fcoury-oai
fcoury-oai merged commit 7a4b344 into main Aug 24, 2026
10 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/ex-shell-filters branch August 24, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant