Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] accept-line: add ZLE_KEEPSUFFIX to preserve completion suffixes
- X-seq: zsh-workers 54283
- From: Dimitry Grebenyuk <dimitrygrebenyuk@xxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] accept-line: add ZLE_KEEPSUFFIX to preserve completion suffixes
- Date: Sat, 4 Apr 2026 15:44:58 +0800
- Archived-at: <https://zsh.org/workers/54283>
- List-id: <zsh-workers.zsh.org>
- Mail-alias-created-date: 1674387736899
From d05437f3c79616be6fdda800d4b38fdc8ddcf9bc Mon Sep 17 00:00:00 2001
From: Dimitry Grebenyuk <46931822+grebenyyk@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 4 Apr 2026 15:20:20 +0800
Subject: [PATCH] accept-line: add ZLE_KEEPSUFFIX to preserve completion
suffixes
When a completion adds a removable suffix (e.g. '/' after a directory
name), the accept-line widget removes it before execution because it
lacks the ZLE_KEEPSUFFIX flag. This causes a mismatch between what is
displayed on screen and what is actually executed.
To reproduce:
mkdir -p .ssh
source .ss<TAB> # completes to 'source .ssh/'
<Enter> # executes 'source .ssh' (no slash)
The trailing '/' is visually present but stripped by removesuffix()
in execzlefunc() before the line buffer is returned for execution.
Fix this by adding ZLE_KEEPSUFFIX to accept-line, accept-and-hold,
and accept-line-and-down-history. This causes fixsuffix() to commit
the suffix permanently rather than removesuffix() stripping it.
This is consistent with accept-and-menu-complete which already has
ZLE_KEEPSUFFIX.
---
Src/Zle/iwidgets.list | 6 +++---
Test/Y01completion.ztst | 10 ++++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Src/Zle/iwidgets.list b/Src/Zle/iwidgets.list
index c95c7a491..fbc962c2a 100644
--- a/Src/Zle/iwidgets.list
+++ b/Src/Zle/iwidgets.list
@@ -8,11 +8,11 @@
# `#' starts a comment. Blank lines are ignored.
#
-"accept-and-hold", acceptandhold, 0
+"accept-and-hold", acceptandhold, ZLE_KEEPSUFFIX
"accept-and-infer-next-history", acceptandinfernexthistory, 0
"accept-and-menu-complete", acceptandmenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX
-"accept-line", acceptline, 0
-"accept-line-and-down-history", acceptlineanddownhistory, 0
+"accept-line", acceptline, ZLE_KEEPSUFFIX
+"accept-line-and-down-history", acceptlineanddownhistory, ZLE_KEEPSUFFIX
"accept-search", NULL, 0
"argument-base", argumentbase, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND
"auto-suffix-remove", handlesuffix, ZLE_NOTCOMMAND
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index d7215f381..f1a2c042e 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -394,6 +394,16 @@ F:regression test workers/31611
>NO:{z}
+ zpty -n -w zsh $': dir1\t\C-X'
+ zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
+ print "failed to invoke finish widget."
+ return 1
+ }
+ print -lr "${(@)${(@ps:\r\n:)log##*<WIDGET><finish>}[2,-2]}"
+0:accept-line preserves completion suffix (directory slash)
+>BUFFER: : dir1/
+>CURSOR: 7
+
%clean
zmodload -ui zsh/zpty
--
2.53.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author