bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] fix COMP_WORDS when completing an empty word


From: Naïm Favier
Subject: [PATCH] fix COMP_WORDS when completing an empty word
Date: Mon, 20 Jun 2022 11:47:29 +0200

Currently, typing `cmd flag1  flag2` (note the two spaces), navigating
between the two spaces and hitting Tab produces
`COMP_WORDS=(cmd flag1 flag2)` without inserting an empty word between
flag1 and flag2.

I believe this comes from considering the cursor ("sentinel") as a block
rather than a line, which does not make sense in a completion context,
but might possibly make sense in other contexts?

Note that this aligns with the behaviour of the default readline
completion.

Signed-off-by: Naïm Favier <n@monade.li>
---
 subst.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/subst.c b/subst.c
index 2b76256c..f3452517 100644
--- a/subst.c
+++ b/subst.c
@@ -2379,11 +2379,6 @@ split_at_delims (string, slen, delims, sentinel, flags, 
nwp, cwp)
       if (sentinel >= ts && sentinel <= te)
        cw = nw;
 
-      /* If the cursor is at whitespace just before word start, set the
-        sentinel word to the current word. */
-      if (cwp && cw == -1 && sentinel == ts-1)
-       cw = nw;
-
       /* If the cursor is at whitespace between two words, make a new, empty
         word, add it before (well, after, since the list is in reverse order)
         the word we just added, and set the current word to that one. */
-- 
2.36.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]