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

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

[nongnu] elpa/bash-completion cc1a462415 050/313: tested complex line, d


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion cc1a462415 050/313: tested complex line, detect escaped separators
Date: Sat, 3 Dec 2022 10:59:15 -0500 (EST)

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

    tested complex line, detect  escaped separators
---
 bash-completion.el      |  6 +++++-
 bash-completion_test.el | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index 3a08e0e11a..fa2f0d03b7 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -125,7 +125,11 @@ Call bash to do the completion."
       (dolist (current accum)
        (let* ((position (bash-completion-tokenize-range-check current pos))
               (string (bash-completion-tokenize-get-str current))
-              (is-terminal (member string '(";" "&" "|" "&&" "||"))))
+              (is-terminal
+               (and (member string '(";" "&" "|" "&&" "||"))
+                    (let ((range (bash-completion-tokenize-get-range current)))
+                      (= (- (cdr range) (car range))
+                         (length string))))))
          (cond
           ((and is-terminal
                 (eq position 'after))
diff --git a/bash-completion_test.el b/bash-completion_test.el
index a96fcd6219..688005598a 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -172,6 +172,39 @@ cases. That's why they need to be enabled manually.")
        (cword . 4)
        (words . ("a" "hello" "world" "b" "c"))))
 
+     ("bash-completion-parse-line complex multi-command line"
+      (sz-testutils-with-buffer
+       '("cd /var/tmp ; ZORG=t make -" cursor " -f Makefile && ./zorg")
+       (bash-completion-parse-line 1 (line-end-position) (point)))
+      '((line . "make - -f Makefile")
+       (cword . 1)
+       (words . ("make" "-" "-f" "Makefile"))))
+
+
+     ("bash-completion-parse-line pipe"
+      (sz-testutils-with-buffer
+       '("ls /var/tmp | sort -" cursor)
+       (bash-completion-parse-line 1 (line-end-position) (point)))
+      '((line . "sort -")
+       (cword . 1)
+       (words . ("sort" "-"))))
+
+     ("bash-completion-parse-line escaped semicolon"
+      (sz-testutils-with-buffer
+       '("find -name '*.txt' -" cursor " -exec echo {} ';' | head")
+       (bash-completion-parse-line 1 (line-end-position) (point)))
+      '((line . "find -name '*.txt' - -exec echo {} ';'")
+       (cword . 3)
+       (words . ("find" "-name" "*.txt" "-" "-exec" "echo" "{}" ";"))))
+
+     ("bash-completion-parse-line at var assignment"
+      (sz-testutils-with-buffer
+       '("cd /var/tmp ; A=f ZORG=t" cursor " make -f Makefile && ./zorg")
+       (bash-completion-parse-line 1 (line-end-position) (point)))
+      '((line . "ZORG=t")
+       (cword . 0)
+       (words . ("ZORG=t"))))
+
      ("bash-completion-split cursor after end"
       (sz-testutils-with-buffer
        '("a hello world b c " cursor)



reply via email to

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