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

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

[nongnu] elpa/bash-completion 7ce100b7eb 006/313: cursor position


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 7ce100b7eb 006/313: cursor position
Date: Sat, 3 Dec 2022 10:58:59 -0500 (EST)

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

    cursor position
---
 bash-complete.el      |  6 ++++--
 bash-complete_test.el | 30 ++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/bash-complete.el b/bash-complete.el
index 8af7b5619b..d12720c2b0 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -77,9 +77,11 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
      (concat straccum (char-to-string (char-before)))))
    ;; word end
    (t
-    (when straccum
-      (setcdr accum (cons straccum (cdr accum))))
     (skip-chars-forward " \t\n\r" end)
+    (when (> (length straccum) 0)
+      (setcdr accum (cons straccum (cdr accum)))
+      (when (and (not (car accum)) (> pos 0) (<= pos (point)))
+       (setcar accum (- (length (cdr accum)) 1))))
     (if (< (point) end)
        (bash-complete-split-0 (point) end pos accum "")
       accum))))
diff --git a/bash-complete_test.el b/bash-complete_test.el
index d3403a7343..ed832ec4b4 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -34,6 +34,12 @@
        (bash-complete-split 1 (line-end-position) 0))
       '(nil . ("a" "hello" "world" "b" "c")))
 
+     ("bash-complete-split simple extra spaces"
+      (sz-testutils-with-buffer
+       '("  a  hello \n world \t b \r c  ")
+       (bash-complete-split 1 (line-end-position 2) 0))
+      '(nil . ("a" "hello" "world" "b" "c")))
+
      ("bash-complete-split escaped space"
       (sz-testutils-with-buffer
        '("a hello\\ world b c")
@@ -70,6 +76,30 @@
        (bash-complete-split 1 (line-end-position) 0))
       '(nil . ("a" "hello world bc" "d")))
 
+     ("bash-complete-split cursor at end of word"
+      (sz-testutils-with-buffer
+       '("a hello world" cursor " b c")
+       (bash-complete-split 1 (line-end-position) (point)))
+      '(2 . ("a" "hello" "world" "b" "c")))
+
+     ("bash-complete-split cursor in the middle of a word"
+      (sz-testutils-with-buffer
+       '("a hello wo" cursor "rld b c")
+       (bash-complete-split 1 (line-end-position) (point)))
+      '(2 . ("a" "hello" "world" "b" "c")))
+
+     ("bash-complete-split cursor at the beginnig"
+      (sz-testutils-with-buffer
+       '(" " cursor " a hello world b c")
+       (bash-complete-split 1 (line-end-position) (point)))
+      '(0 . ("a" "hello" "world" "b" "c")))
+
+     ("bash-complete-split cursor in the middle"
+      (sz-testutils-with-buffer
+       '("a hello " cursor " world b c")
+       (bash-complete-split 1 (line-end-position) (point)))
+      '(1 . ("a" "hello" "world" "b" "c")))
+
       )))
 
 



reply via email to

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