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

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

[nongnu] elpa/flx f1851c8983 037/182: treat last *non-zero* segment as b


From: ELPA Syncer
Subject: [nongnu] elpa/flx f1851c8983 037/182: treat last *non-zero* segment as basename
Date: Tue, 13 Dec 2022 03:59:23 -0500 (EST)

branch: elpa/flx
commit f1851c8983d3d8eeeec4506c2e9a01f9e349f70c
Author: Le Wang <le.wang@agworld.com.au>
Commit: Le Wang <le.wang@agworld.com.au>

    treat last *non-zero* segment as basename
    
    - for paths like "foo/", basename should be "foo"
    
    fixes #12
---
 flx.el            |  9 +++++++--
 tests/flx-test.el | 10 +++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/flx.el b/flx.el
index 3147999f3c..0588f2d072 100644
--- a/flx.el
+++ b/flx.el
@@ -13,7 +13,7 @@
 ;; Version: 0.1
 ;; Last-Updated:
 ;;           By:
-;;     Update #: 13
+;;     Update #: 15
 ;; URL:
 ;; Keywords:
 ;; Compatibility:
@@ -169,11 +169,16 @@ See documentation for logic."
       (loop for group in groups-alist
             for index from separator-count downto 0
             with last-group-limit = nil
+            with basepath-found = nil
             do (let ((group-start (car group))
                      (word-count (cadr group))
                      ;; this is the number of effective word groups
                      (words-length (length (cddr group)))
-                     (basepath-p (not last-group-limit)))
+                     basepath-p)
+                 (when (and (not (zerop words-length))
+                            (not basepath-found))
+                   (setq basepath-found t)
+                   (setq basepath-p t))
                  (let (num)
                    (setq num
                          (if basepath-p
diff --git a/tests/flx-test.el b/tests/flx-test.el
index 23d8f12960..7283e584b9 100644
--- a/tests/flx-test.el
+++ b/tests/flx-test.el
@@ -13,7 +13,7 @@
 ;; Version: 0.1
 ;; Last-Updated:
 ;;           By:
-;;     Update #: 9
+;;     Update #: 10
 ;; URL:
 ;; Keywords:
 ;; Compatibility:
@@ -360,6 +360,14 @@ substring can overpower abbreviation."
     (should (= (car score1) (car score2)))))
 
 
+(ert-deftest flx-basepath-is-last-segment ()
+  "For a path like \"bar/foo/\" the basename should be foo"
+  (let* ((query "def")
+         (higher (flx-score "defuns/" query (flx-make-filename-cache)))
+         (lower (flx-score "sane-defaults.el" query 
(flx-make-filename-cache))))
+    (should (> (car higher) (car lower)))))
+
+
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; flx-test.el ends here



reply via email to

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