Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Luca Boccassi Newsgroups: gnu.bash.bug Subject: [PATCH] initial word completion: fix completion of prefix Date: Fri, 9 Nov 2018 18:52:17 +0000 Lines: 65 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Trace: usenet.stanford.edu 1541789559 18130 208.118.235.17 (9 Nov 2018 18:52:39 GMT) X-Complaints-To: action@cs.stanford.edu Cc: Luca Boccassi To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+Fv7jZDNkrol46gcJaO6quZY0YTyje0djMwbqxd/MdU=; b=uODtBA2izSoM38IkrDBomOdt1aUgKikhrwAmlUUTkGVh537e4Hs35d9IHTjny7cVYj 6ribHmJBoYgRBd9Je6aN0PPg1uwekaTWLHAHnXM3wJ04oBOh5xLXQVprdfc/OscvgWee p5kBinUtAccNBNAeYf0/RFvomyCIz0OpTqOurjLmLjYIQ9TQ22fMgd4K3d//Lauu0Djn 1FF6A3OCR+sKKuucUu7XBCJz7W54uDqVcCvC1TkCMKQaZCs8CiG1tAyA36wpF9c1zl+l Wl4GZ7uDiSY0B9Gxpom4fjZ4WmOhlqoRrCq+DIcKeszuLKGnzARHrPfSbW2Utue6LaI1 ZduQ== X-Gm-Message-State: AGRZ1gL0SRqFBA6MaSCTiY0EAw32EH6SUJM2dbeU2amZ00Q1LKi4N5Ww MxGkT1dwcUOlMUX7s3tnDkxxktcL X-Google-Smtp-Source: AJdET5eFX6MqImFi4+igzc2mmU+meyb46bbBy3QopHEStPNsOpCDsV0mLaaT4nhP/mK/zlz//ClVOw== X-Received: by 2002:a5d:6b43:: with SMTP id x3-v6mr6864498wrw.304.1541789541956; Fri, 09 Nov 2018 10:52:21 -0800 (PST) X-Mailer: git-send-email 2.19.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.68 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14790 If the user types: gcfile.c And positions the cursor of 'f', a programmable completion enabled on initial word (-I) will fail to run. This is because the parsing gives priority first to the _minimal programmable completion that does nothing, and then if that is disabled it gives the next priority to command completion, unlike what happens when completing a full word, stopping the initial word completion from working. To reproduce: cat > repro< --- Dear maintainer, This is the simplest and cleanest solution I could find. I'm happy to test alternative bug fixes if necessary. Thanks! bashline.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bashline.c b/bashline.c index 0d39714f..83ef3fa8 100644 --- a/bashline.c +++ b/bashline.c @@ -1580,8 +1580,11 @@ attempt_shell_completion (text, start, end) else if (e > s && was_assignment == 0 && have_progcomps) { prog_complete_matches = programmable_completions (n, text, s, e, &foundcs); - /* command completion if programmable completion fails */ - in_command_position = s == start && STREQ (n, text); /* XXX */ + /* command completion if programmable completion fails. + Initial word completion can be done on prefix: gcfile.c -> gcc file.c + when tabbing with cursor on 'f' and needs to have precedence over cmd completion. */ + in_command_position = s == start && (iw_compspec || STREQ (n, text)); /* XXX */ + foundcs = foundcs && !iw_compspec; } /* empty command name following command separator */ else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0 && -- 2.19.1