Skip to content

Commit 815d417

Browse files
committed
matlab-shell: fix TAB completion for case of early completion
When computing completions for TAB, if we "did-completion", don't call complete-in-region because that was causing a "No match" message even when we did the completion, e.g. cd2 $d.
1 parent 4c3064f commit 815d417

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

matlab-shell.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ No completions are provided anywhere else in the buffer."
14731473
(let* ((completion-list (matlab-shell-completion-list last-cmd-quoted))
14741474
(cmd-text-to-replace (cdr (assoc 'cmd-text-to-replace completion-list))))
14751475
(setq completions (cdr (assoc 'completions completion-list)))
1476-
(when cmd-text-to-replace
1476+
(when (and cmd-text-to-replace (not (string= cmd-text-to-replace "")))
14771477
;; need to alter the command to replace replacement-text with the common substring
14781478
(let ((replacement-text (cdr (assoc 'replacement-text completion-list)))
14791479
(last-cmd-start-len (- (length last-cmd) (length cmd-text-to-replace))))
@@ -1519,7 +1519,6 @@ No completions are provided anywhere else in the buffer."
15191519
(cons 'did-completion did-completion)
15201520
))))
15211521

1522-
15231522
(defun matlab-shell-c-tab ()
15241523
"Send [TAB] to the currently running matlab process and retrieve completions."
15251524
(interactive)
@@ -1608,9 +1607,10 @@ installed, then use company to display completions in a popup window."
16081607
(let* ((inhibit-field-text-motion t)
16091608
(completion-info (matlab-shell-get-completion-info))
16101609
(completions (cdr (assoc 'completions completion-info)))
1610+
(did-completion (cdr (assoc 'did-completion completion-info)))
16111611
(common-substr-start-pt (cdr (assoc 'common-substr-start-pt completion-info)))
16121612
(common-substr-end-pt (cdr (assoc 'common-substr-end-pt completion-info))))
1613-
(when (and common-substr-start-pt common-substr-end-pt)
1613+
(when (and (not did-completion) common-substr-start-pt common-substr-end-pt)
16141614
(completion-in-region common-substr-start-pt common-substr-end-pt completions))))
16151615

16161616
(defun matlab-shell-do-completion ()

0 commit comments

Comments
 (0)