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

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

[elpa] externals/ivy-hydra 5e67e7c 268/395: counsel.el (counsel-rg): Spl


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 5e67e7c 268/395: counsel.el (counsel-rg): Split command args independent of the order
Date: Thu, 25 Feb 2021 08:32:17 -0500 (EST)

branch: externals/ivy-hydra
commit 5e67e7c3ddb0c4df3989267ced88b1290af2dc28
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    counsel.el (counsel-rg): Split command args independent of the order
    
    * ivy-test.el (counsel--split-command-args): Add test.
    
    Both:
    
        require i -- -g*.el
    
    and:
    
        -g*.el -- require
    
    are vaild and result in the same search.
    
    Fixes #2547
---
 counsel.el  | 8 +++++---
 ivy-test.el | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/counsel.el b/counsel.el
index 431ba23..2ad5fbf 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2956,9 +2956,11 @@ regex string."
   "Split ARGUMENTS into its switches and search-term parts.
 Return pair of corresponding strings (SWITCHES . SEARCH-TERM)."
   (if (string-match counsel--command-args-separator arguments)
-      (cons
-       (substring arguments (match-end 0))
-       (substring arguments 0 (match-beginning 0)))
+      (let ((args (substring arguments (match-end 0)))
+            (search-term (substring arguments 0 (match-beginning 0))))
+        (if (string-prefix-p "-" arguments)
+            (cons search-term args)
+          (cons args search-term)))
     (cons "" arguments)))
 
 (defun counsel--format-ag-command (extra-args needle)
diff --git a/ivy-test.el b/ivy-test.el
index 599f840..08ffb6e 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1543,6 +1543,9 @@ a buffer visiting a file."
            (counsel--split-command-args "require -- -g*.el")
            '("-g*.el" . "require")))
   (should (equal
+           (counsel--split-command-args "-g*.el -- require")
+           '("-g*.el" . "require")))
+  (should (equal
            (counsel--split-command-args "counsel--format")
            '("" . "counsel--format"))))
 



reply via email to

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