jcs-elpa / flx-rs

flx in Rust using dynamic module
GNU General Public License v3.0
22 stars 8 forks source link

一个奇怪的不匹配 #14

Closed lynnux closed 2 years ago

lynnux commented 2 years ago

我用的fussy,配置:

(use-package fussy
      :init
      :config
      (setq 
       completion-category-overrides '((multi-category (styles fussy))
                                       (file (styles fussy))
                                       )
       )
      )
(use-package flx-rs
      :init
      (setq fussy-score-fn 'flx-rs-score)
      (ignore-errors (module-load "c:/green/emacs/.emacs.d/packages/minibuffer/flx-rs.x86_64-pc-windows-msvc.dll"))
      )

如果不用flx-rs的话,packex是可以匹配package_extra.el的,但是设置了(setq fussy-score-fn 'flx-rs-score)就不能匹配了。但是我用(flx-rs-score "package_extra.el" "packex")测试结果(424 0 1 2 3 8 9)不是nil应该是匹配上了。 然后测试https://github.com/dangduc/fzf-native配合fussy也是可以的,所以可能是flx-rs的bug?

jcs090218 commented 2 years ago

如果用 flx-rs-score, 可以匹配上, 那應該就不是這個package的問題! 因為這個package, 也就只負責這項工作。 你可以試試flx, 看會不會得到相同結果!?

lynnux commented 2 years ago

(flx-score "package_extra.el" "packex") 结果也是(424 0 1 2 3 8 9)。 我用advice查看结果

(defadvice flx-rs-score (around my-flx-rs-score activate)
  ad-do-it
  (message "str:%s,query:%s,ret:%S" (ad-get-arg 0) (ad-get-arg 1) ad-return-value)
  )
(defadvice flx-score (around my-flx-score activate)
  ad-do-it
  (message "str:%s,query:%s,ret:%S" (ad-get-arg 0) (ad-get-arg 1) ad-return-value)
  )

结果(setq fussy-score-fn 'flx-rs-score)如下: 图片 (setq fussy-score-fn 'flx-score)如下 图片 所以貌似是flx-rs-score全部返回nil了?而fussy是先filter后score所以其实显示的都是filter的结果?严重怀疑是str结尾乱码的原因。

lynnux commented 2 years ago

就是乱码问题 图片 这样就回返回nil(可以用C-x 8 RET 20003来输入乱码)。参考fussy-fzf-native-score写一个去掉乱码的就可以了:

  (defun fussy-flx-rs-score (str query &rest _args)
    (let ((str (funcall fussy-remove-bad-char-fn str))
          (query (fussy-encode-coding-string query)))
      (flx-rs-score str query))
    )
  (setq fussy-score-fn 'fussy-flx-rs-score)
jcs090218 commented 2 years ago

那這個可能就是個bug了! 沒想到亂碼會導致無法匹配...

jcs090218 commented 7 months ago

這個問題已解決了, 看 https://github.com/jcs090218/flx-rs/commit/3f18a216054fae8cee5ff36783a80c72a7a64f93.