emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/bash-completion 3ffc296e0b 149/313: Close opened quote for


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 3ffc296e0b 149/313: Close opened quote for all completion candidate that don't end with a
Date: Sat, 3 Dec 2022 10:59:25 -0500 (EST)

branch: elpa/bash-completion
commit 3ffc296e0be0e9a762e935d5dc46528cb4c72217
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>

    Close opened quote for all completion candidate that don't end with a
    special character. Add a space afterwards, if it is a single candidate
    or a command completion.
    
    fixes #20
---
 bash-completion-test.el | 29 +++++++++++++++++++++++++++--
 bash-completion.el      | 16 +++++++++-------
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/bash-completion-test.el b/bash-completion-test.el
index 4c4902c457..1fcd7cba49 100644
--- a/bash-completion-test.el
+++ b/bash-completion-test.el
@@ -745,6 +745,31 @@ before calling `bash-completion-dynamic-complete-nocomint'.
             '("hello ")
             (nth 2 (bash-completion-dynamic-complete-nocomint 3 (point)))))))
 
+
+(ert-deftest bash-completion-single-completion-double-quotes ()
+  (--with-fake-bash-completion-send
+   (push "hello\n" --send-results)
+   (insert "$ cat \"he")
+   (should (equal
+            '("hello\" ")
+            (nth 2 (bash-completion-dynamic-complete-nocomint 3 (point)))))))
+
+(ert-deftest bash-completion-single-completion-single-quotes ()
+  (--with-fake-bash-completion-send
+   (push "hello\n" --send-results)
+   (insert "$ cat 'he")
+   (should (equal
+            '("hello' ")
+            (nth 2 (bash-completion-dynamic-complete-nocomint 3 (point)))))))
+
+(ert-deftest bash-completion-completion-with-double-quotes ()
+  (--with-fake-bash-completion-send
+   (push "hell\nhello\n" --send-results)
+   (insert "$ cat \"he")
+   (should (equal
+            '("hell\"" "hello\"")
+            (nth 2 (bash-completion-dynamic-complete-nocomint 3 (point)))))))
+
 (ert-deftest bash-completion-trailing-default-completion ()
   (--with-fake-bash-completion-send
    (push "without space\nwith space \nwith slash/\n" --send-results)
@@ -840,8 +865,8 @@ before calling `bash-completion-dynamic-complete-nocomint'.
    (push "Documents/Modes d'emplois/KAR 1.pdf\nDocuments/Modes d'emplois/KAR 
2.pdf\n"
          --send-results)
    (should (equal
-            '("Documents/Modes d'\\''emplois/KAR 1.pdf"
-              "Documents/Modes d'\\''emplois/KAR 2.pdf")
+            '("Documents/Modes d'\\''emplois/KAR 1.pdf'"
+              "Documents/Modes d'\\''emplois/KAR 2.pdf'")
             (nth 2 (bash-completion-dynamic-complete-nocomint 3 (point)))))))
 
 (ert-deftest bash-completion-complete-command-with-dir ()
diff --git a/bash-completion.el b/bash-completion.el
index 141dfdc22e..89d953e631 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -815,11 +815,13 @@ for directory name detection to work."
      (t (setq rest str)))
 
     ;; build suffix
-    (let ((last-char (bash-completion-last-char rest)))
+    (let ((last-char (bash-completion-last-char rest))
+          (close-quote-str (if open-quote (char-to-string open-quote) ""))
+          (final-space-str (if bash-completion-nospace "" " ")))
       (cond
        ((eq ?\  last-char)
         (setq rest (substring rest 0 -1))
-        (setq suffix (if bash-completion-nospace "" " ")))
+        (setq suffix (concat close-quote-str final-space-str)))
        ((or (memq last-char bash-completion-wordbreaks)
             (eq ?/ last-char))
         (setq suffix ""))
@@ -830,11 +832,11 @@ for directory name detection to work."
                              open-quote (concat parsed-prefix rest))
                             default-directory)))
         (setq suffix "/"))
-       ((and (not open-quote)
-             (or (eq completion-type 'command)
-                 (and (memq completion-type '(default wordbreak custom))
-                      single)))
-        (setq suffix (if bash-completion-nospace "" " ")))))
+       ((or (eq completion-type 'command)
+            (and (memq completion-type '(default wordbreak custom))
+                 single))
+        (setq suffix (concat close-quote-str final-space-str)))
+       (t (setq suffix close-quote-str))))
 
     ;; put everything back together
     (concat unparsed-prefix



reply via email to

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