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

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

[nongnu] elpa/bash-completion 9f02a62609 049/313: re-enabled parse-line


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 9f02a62609 049/313: re-enabled parse-line cursor at the beginning/in the middle tests
Date: Sat, 3 Dec 2022 10:59:15 -0500 (EST)

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

    re-enabled parse-line cursor at the beginning/in the middle tests
---
 bash-completion.el      | 14 +++--------
 bash-completion_test.el | 63 ++++++++++++-------------------------------------
 2 files changed, 18 insertions(+), 59 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 7466c859bd..3a08e0e11a 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -46,7 +46,7 @@ Call bash to do the completion."
   (when (not (window-minibuffer-p))
     (message "Bash completion..."))
   (let* ( (pos (point))
-         (start (bash-completion-line-beginning-position))
+         (start (comint-line-beginning-position))
          (end (line-end-position))
          (parsed (bash-completion-parse-line start end pos))
          (line (cdr (assq 'line parsed)))
@@ -65,15 +65,6 @@ Call bash to do the completion."
            (bash-completion-send (concat (bash-completion-cd-command-prefix) 
"compgen -o default -- " after-wordbreak))
            (comint-dynamic-simple-complete after-wordbreak 
(bash-completion-extract after-wordbreak))))))))
 
-(defun bash-completion-line-beginning-position (&optional start)
-  (save-excursion
-    (let ((start (or start (comint-line-beginning-position)))
-         (end (line-end-position)))
-      (goto-char end)
-      (if (search-backward-regexp "\\(;\\|\\(&&\\)\\|\\(||\\)\\)[ \t\n]" start 
t)
-         (match-end 0)
-       start))))
-
 (defun bash-completion-join (words)
   "Join WORDS into a shell line, escaped all words with single quotes"
   (if words
@@ -104,7 +95,8 @@ Call bash to do the completion."
 
 (defun bash-completion-parse-line-postprocess (accum pos)
   (let ((index 0) (strings nil) (current nil) (accum-rest accum) (cword nil)
-       (start (car (bash-completion-tokenize-get-range (car accum)))))
+       (start (min pos
+                   (car (bash-completion-tokenize-get-range (car accum))))))
     (while accum-rest
       (setq current (car accum-rest))
       (setq accum-rest (cdr accum-rest))
diff --git a/bash-completion_test.el b/bash-completion_test.el
index edc28eff1c..a96fcd6219 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -148,17 +148,21 @@ cases. That's why they need to be enabled manually.")
        (cword . 2)
        (words . ("a" "hello" "world" "b" "c"))))
 
-;;      ("bash-completion-split cursor at the beginning"
-;;       (sz-testutils-with-buffer
-;;        '(" " cursor " a hello world b c")
-;;        (bash-completion-split 1 (line-end-position) (point)))
-;;       '(0 . ("" "a" "hello" "world" "b" "c")))
-
-;;      ("bash-completion-split cursor in the middle"
-;;       (sz-testutils-with-buffer
-;;        '("a hello " cursor " world b c")
-;;        (bash-completion-split 1 (line-end-position) (point)))
-;;       '(2 . ("a" "hello" "" "world" "b" "c")))
+     ("bash-completion-parse-line cursor at the beginning"
+      (sz-testutils-with-buffer
+       '(" " cursor " a hello world b c")
+       (bash-completion-parse-line 1 (line-end-position) (point)))
+      '((line . " a hello world b c")
+       (cword . 0)
+       (words . ("" "a" "hello" "world" "b" "c"))))
+
+     ("bash-completion-parse-line cursor in the middle"
+      (sz-testutils-with-buffer
+       '("a hello " cursor " world b c")
+       (bash-completion-parse-line 1 (line-end-position) (point)))
+      '((line . "a hello  world b c")
+       (cword . 2)
+       (words . ("a" "hello" "" "world" "b" "c"))))
 
      ("bash-completion-parse-line cursor at end"
       (sz-testutils-with-buffer
@@ -263,43 +267,6 @@ garbage
        (bash-completion-generate-line "zorg worl" 7 '("zorg" "worl") 1))
       "cd 2>/dev/null /test ; __BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg 
worl'\\''; COMP_POINT=7; COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg 
\"${COMP_WORDS[@]}\"' compgen -F __bash_complete_wrapper -- worl")
 
-     ("bash-completion-line-beginning-position start"
-      (sz-testutils-with-buffer
-       "cd /home/x"
-       (bash-completion-line-beginning-position 1))
-      1)
-
-     ("bash-completion-line-beginning-position semicolon"
-      (sz-testutils-with-buffer
-       '("cd /home/x ; " cursor "echo hello")
-       (list
-       (point)
-       (bash-completion-line-beginning-position 1)))
-      '(14 14))
-
-     ("bash-completion-line-beginning-position 2 semicolon"
-      (sz-testutils-with-buffer
-       '("cd /home/x ; blah; " cursor "echo hello")
-       (list
-       (point)
-       (bash-completion-line-beginning-position 1)))
-      '(20 20))
-
-     ("bash-completion-line-beginning-position &&"
-      (sz-testutils-with-buffer
-       '("cd /home/x && " cursor "echo hello")
-       (list
-       (point)
-       (bash-completion-line-beginning-position 1)))
-      '(15 15))
-
-     ("bash-completion-line-beginning-position ||"
-      (sz-testutils-with-buffer
-       '("cd /home/x || " cursor "echo hello")
-       (list
-       (point)
-       (bash-completion-line-beginning-position 1)))
-      '(15 15))
 
      ("bash-completion-starts-with empty str"
       (bash-completion-starts-with "" "prefix")



reply via email to

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