Subject: bug#18951: eshell-pcomplete removes asterisk when attempting completion

From: Noam Postavsky <[email-masked]>
Date: Thu, 02 Nov 2017 07:32:13 -0400

Daniel Kraus <[email-masked]> writes:

> Noam Postavsky <[email-masked]> writes:
>
>> A good start would be to step through eshell-pcomplete with edebug and
>> find the piece of code which deletes the asterisk.
>
> It's in `pcomplete-parse-arguments` (in pcomplete.el)
> Line 776 on master:
> ```
>       (when (and begin (not pcomplete-show-list))
> 	(delete-region begin (point))
> 	(pcomplete-insert-entry "" pcomplete-stub))
> ```

Hmm, does this do the right thing?

--- i/lisp/pcomplete.el
+++ w/lisp/pcomplete.el
@@ -772,7 +772,7 @@ pcomplete-parse-arguments
 		(setq c (cdr c)))
 	      (setq pcomplete-stub (substring common-stub 0 len)
 		    pcomplete-autolist t)
-	      (when (and begin (not pcomplete-show-list))
+	      (when (and begin (> len 0) (not pcomplete-show-list))
 		(delete-region begin (point))
 		(pcomplete-insert-entry "" pcomplete-stub))
 	      (throw 'pcomplete-completions completions))