branch: externals/dape
commit 930a03902156eeb468f4b864b7d5cd7e5015280d
Author: Daniel Pettersson <dan...@dpettersson.net>
Commit: Daniel Pettersson <dan...@dpettersson.net>

    Filter out dape command repl completions if not valid input
    
    Add `dape-repl-commands' only if completion starts at `bolp' as
    `dape-repl-commands' is only valid if input `equals' command key.
---
 dape.el | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/dape.el b/dape.el
index 6c06223c34..c7e6ff6856 100644
--- a/dape.el
+++ b/dape.el
@@ -4151,8 +4151,6 @@ Send INPUT to DUMMY-PROCESS."
   ;;       - compleation is messed up if point is in text and
   ;;         compleation is triggered
   ;;       - compleation is done on whole line for `debugpy'
-  ;;       - compleation for dape commands should only be valid when
-  ;;         command is starts at `bolp'
   (when (or (symbol-at-point)
             (member (buffer-substring-no-properties (1- (point)) (point))
                     (or (thread-first (dape--live-connection 'last t)
@@ -4170,14 +4168,18 @@ Send INPUT to DUMMY-PROCESS."
                  (car bounds)
                  (cdr bounds)))
            (collection
-            (mapcar (lambda (cmd)
-                      (cons (car cmd)
-                            (format " %s"
-                                    (propertize (symbol-name (cdr cmd))
-                                                'face 
'font-lock-builtin-face))))
-                    (append dape-repl-commands
-                            (when dape-repl-use-shorthand
-                              (dape--repl-shorthand-alist)))))
+            ;; Add `dape-repl-commands' only if completion starts at
+            ;; `bolp' as `dape-repl-commands' is only valid if input
+            ;; `equals' command key.
+            (when (eql (car bounds) (line-beginning-position))
+              (mapcar (lambda (cmd)
+                        (cons (car cmd)
+                              (format " %s"
+                                      (propertize (symbol-name (cdr cmd))
+                                                  'face 
'font-lock-builtin-face))))
+                      (append dape-repl-commands
+                              (when dape-repl-use-shorthand
+                                (dape--repl-shorthand-alist))))))
            done)
       (list
        (car bounds)

Reply via email to