1414#
1515# Requirements: agent-tty, python3, and one or more Neovim builds.
1616# The bug is version-dependent (fixed upstream by neovim/neovim#39152, in 0.12.2):
17- # * Neovim 0.11.x / 0.12.1 -> reproduces (N segments)
18- # * Neovim 0.12.2+ -> single segment
19- # Install older builds with mise, e.g.: mise install neovim@0.11.6
17+ # * Neovim 0.11.x / 0.12.0 / 0.12.1 -> reproduces (N segments)
18+ # * Neovim 0.12.2+ -> single segment
2019#
2120# Usage:
22- # ./agent-repro.sh # uses `nvim` on PATH, default + workaround
21+ # ./agent-repro.sh # uses `nvim` on PATH
22+ # NVIM_VERSION=0.11.7 ./agent-repro.sh # run an old Neovim via mise (recommended)
2323# NVIM_BIN=/path/to/nvim ./agent-repro.sh
24- # LINES=300 ./agent-repro.sh # bigger payload
24+ # LINES=300 ./agent-repro.sh # bigger payload
25+ #
26+ # NVIM_VERSION resolves the binary through mise. mise installs versions
27+ # side-by-side under its own cache, so this NEVER changes your active/default
28+ # Neovim (that only changes via `mise use`). To run one off without this script:
29+ # mise exec neovim@0.11.7 -- nvim ...
2530set -uo pipefail
2631
2732HERE=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
2833FIX_DIR=" $( dirname " $HERE " ) " # .../fixtures
29- NVIM=" ${NVIM_BIN:- $(command -v nvim)} "
3034LINES=" ${LINES:- 120} "
3135export _ZO_DOCTOR=0
3236
37+ # Resolve how to launch Neovim (used both verbatim and embedded in a `bash -lc`):
38+ # explicit NVIM_BIN > NVIM_VERSION (via `mise exec`, side-by-side/ephemeral) > `nvim` on PATH.
39+ # `mise exec neovim@X -- nvim` resolves the managed tool directly, so it is not affected by other
40+ # nvim managers on PATH and never changes your active Neovim.
41+ if [ -n " ${NVIM_BIN:- } " ]; then
42+ NVIM=" $NVIM_BIN "
43+ elif [ -n " ${NVIM_VERSION:- } " ]; then
44+ command -v mise > /dev/null || {
45+ echo " ERROR: NVIM_VERSION set but mise not found on PATH"
46+ exit 1
47+ }
48+ mise install " neovim@$NVIM_VERSION " > /dev/null 2>&1 || true
49+ NVIM=" mise exec neovim@$NVIM_VERSION -- nvim"
50+ else
51+ NVIM=" nvim"
52+ fi
53+
3354command -v agent-tty > /dev/null || {
3455 echo " ERROR: agent-tty not found on PATH"
3556 exit 1
@@ -38,8 +59,11 @@ command -v python3 >/dev/null || {
3859 echo " ERROR: python3 not found on PATH"
3960 exit 1
4061}
41- [ -x " $NVIM " ] || {
42- echo " ERROR: nvim not found (set NVIM_BIN)"
62+ # $NVIM may be a path, "nvim", or "mise exec neovim@X -- nvim", so smoke-test it
63+ # (unquoted, to word-split the launcher) rather than checking for an executable file.
64+ # shellcheck disable=SC2086
65+ $NVIM --version > /dev/null 2>&1 || {
66+ echo " ERROR: could not run Neovim ('$NVIM '); set NVIM_BIN or NVIM_VERSION"
4367 exit 1
4468}
4569
@@ -56,7 +80,8 @@ path, n = sys.argv[1], int(sys.argv[2])
5680open(path, "w").write("\n".join("L%03d: the quick brown fox jumps over the lazy dog" % i for i in range(1, n+1)) + "\n")
5781PY
5882echo " Payload: $LINES lines, $( wc -c < " $PAYLOAD " ) bytes"
59- echo " Neovim: $( " $NVIM " --version | head -1) "
83+ # shellcheck disable=SC2086
84+ echo " Neovim: $( $NVIM --version | head -1) "
6085echo
6186
6287run () { # run <apply_fix 0|1> <label>
@@ -66,7 +91,7 @@ run() { # run <apply_fix 0|1> <label>
6691 local a=(agent-tty --home " $AGENT_HOME " )
6792 local sid
6893 sid=" $( " ${a[@]} " create --json --cols 110 --rows 32 -- \
69- bash -lc " cd '$FIX_DIR ' && PASTE_OBSERVER_LOG='$log ' APPLY_PASTE_FIX='$fix ' PASTE_REPRO_AUTOOPEN=1 NVIM_APPNAME=paste-repro XDG_CONFIG_HOME='$FIX_DIR ' ' $NVIM ' --clean -u '$FIX_DIR /paste-repro/init.lua'" |
94+ bash -lc " cd '$FIX_DIR ' && PASTE_OBSERVER_LOG='$log ' APPLY_PASTE_FIX='$fix ' PASTE_REPRO_AUTOOPEN=1 NVIM_APPNAME=paste-repro XDG_CONFIG_HOME='$FIX_DIR ' $NVIM --clean -u '$FIX_DIR /paste-repro/init.lua'" |
7095 python3 -c " import json,sys;print(json.load(sys.stdin)['result']['sessionId'])" ) "
7196 " ${a[@]} " wait " $sid " --text ' OBSERVER READY' --timeout-ms 15000 --json > /dev/null 2>&1
7297 " ${a[@]} " paste " $sid " " $( cat " $PAYLOAD " ) " --json > /dev/null 2>&1
0 commit comments