You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(terminal): harden paste shim per code review (#161)
Address findings from a max-effort review of the streamed-paste shim:
- Fixture repro was self-defeating: the plugin's own fix_streamed_paste="auto"
coalesced the paste on exactly the affected Neovim versions, so the
agent-repro.sh "default" run could never observe the bug. The fixture now sets
fix_streamed_paste=false by default (raw repro), with PASTE_REPRO_PLUGIN_FIX
to opt into exercising the shipped fix.
- Harden the hot path: is_managed_terminal() now pcall-guards
get_active_terminal_bufnr() (provider resolution could throw and break pasting
editor-wide) and caches the lazily-required terminal module instead of
pcall(require) on every phase.
- Latch the managed-terminal decision once per stream at phase 1 and reuse it
for phases 2/3. This resolves the provider only once per paste (not per phase)
and keeps buffered content intact if focus changes mid-stream (previously a
mid-stream focus change stranded phases 1/2 and mis-delegated phase 3).
- Make the config dynamic: an `enabled` flag is checked in the override, so a
later setup() with fix_streamed_paste=false disables it without needing to
uninstall/restore the global vim.paste.
- is_affected_version: guard v.minor like v.patch ((v.minor or 0)) to avoid a
nil comparison on a malformed version table.
- Simplify _accumulate to a single append loop.
- Tests: add phase-2 (1->2->3) coverage, a mid-stream focus-change case, and a
dynamic-disable case (26 unit tests).
Skipped (noted, not applied): switching the version gate to vim.fn.has() (the
explicit, tested vim.version() check avoids patch-level has() support risk);
a buffer-local/TermOpen-based marker instead of the global override (correct
altitude but touches provider internals outside this change — the latch + pcall
capture most of the benefit); cosmetic divergences from the default handler
(progress dots, empty-chunk skip) which were verified to produce byte-identical
output.
Change-Id: I0e3fc55dc517c98cde042a8c1babea2e7e45bed3
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
0 commit comments