jojojames / fussy

Emacs completion-style leveraging flx / fzf / etc
GNU General Public License v3.0
132 stars 12 forks source link

Some result candidates do not appear when using flx-rs #38

Closed Eason0210 closed 2 days ago

Eason0210 commented 11 months ago

@jojojames and @jcs090218

When using the default backend flx, everthing is working well, but when the number of candidates is large (such as 10000 and more), it is slow. So I tried to use the faster backend flx-rs.

But Some result candidates do not appear when using flx-rs with M-x consult-imenu or M-x consult-line .

steps to reprodue:

  1. create and empty file ~/.emacs.d/init.el
  2. put the below minimal code in the init.el file
    
    ;;; init.el --- user-init-file                    -*- lexical-binding: t -*-

(require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))

(package-initialize) (package-refresh-contents)

(eval-and-compile (setq use-package-enable-imenu-support t) (setq use-package-expand-minimally t) (require 'use-package))

(use-package flx-rs :load-path "~/src/packages/flx-rs/" :config (setq fussy-score-fn 'fussy-flx-rs-score) (flx-rs-load-dyn))

(use-package fussy :ensure t :custom (completion-styles '(fussy basic)) (completion-category-defaults nil) (completion-category-overrides '((file (styles basic partial-completion)) (eglot (styles fussy basic)))) (fussy-score-fn 'fussy-flx-rs-score) (fussy-filter-fn 'fussy-filter-default) (fussy-use-cache t) :config (advice-add 'corfu--capf-wrapper :before 'fussy-wipe-cache) (add-hook 'corfu-mode-hook (lambda () (setq-local fussy-max-candidate-limit 5000 fussy-default-regex-fn 'fussy-pattern-first-letter fussy-prefer-prefix nil))))

(use-package vertico :ensure t :demand t :bind (:map vertico-map ([tab] . vertico-next) ([backtab] . vertico-previous)) :custom (vertico-cycle t) :config (vertico-mode))

;; Example configuration for Consult (use-package consult :ensure t :bind (;; C-c bindings in mode-specific-map' ("C-c M-x" . consult-mode-command) ("C-c h" . consult-history) ("C-c k" . consult-kmacro) ("C-c m" . consult-man) ("C-c i" . consult-info) ([remap Info-search] . consult-info) ;; C-x bindings inctl-x-map' ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command ("C-x b" . consult-buffer) ;; orig. switch-to-buffer ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame ("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer ;; Custom M-# bindings for fast register access ("M-#" . consult-register-load) ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) ("C-M-#" . consult-register) ;; Other custom bindings ("M-y" . consult-yank-pop) ;; orig. yank-pop ;; M-g bindings in goto-map' ("M-g e" . consult-compile-error) ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck ("M-g g" . consult-goto-line) ;; orig. goto-line ("M-g M-g" . consult-goto-line) ;; orig. goto-line ("M-g o" . consult-outline) ;; Alternative: consult-org-heading ("M-g m" . consult-mark) ("M-g k" . consult-global-mark) ("M-g i" . consult-imenu) ("M-g I" . consult-imenu-multi) ;; M-s bindings insearch-map' ("M-s d" . consult-find) ;; Alternative: consult-fd ("M-s c" . consult-locate) ("M-s g" . consult-grep) ("M-s G" . consult-git-grep) ("M-s r" . consult-ripgrep) ("M-s l" . consult-line) ("M-s L" . consult-line-multi) ("M-s k" . consult-keep-lines) ("M-s u" . consult-focus-lines))

3. clone flx-rs to `~/src/packages/`
```bash
git clone https://github.com/jcs-elpa/flx-rs.git ~/src/packages/flx-rs
  1. start Emacs,it will install the related packages
  2. open the init.el file by C-x C-f ~/.emacs.d/init.el
  3. M-x consult-imenu you will see all the candidates as below, so far so good.
image
  1. Then you type a character c in the minibuffer prompt, you will get no candiates. This is the issue.
image

if I disable the flx-rs and use flx, the result is as below: I don't known why the "fussy" can match the c??

image

when input co, the result is expected:

image
jcs090218 commented 11 months ago

I can reproduce this bug. I will need to dig into the source code to figure out this bug. 🤔 Thanks for the detailed steps to reproduce this bug!

Edit: How to reproduce this bug with Eask: (for future references)

# Create test project and navigate to the created project
$ mkdir test-fussy && cd test-fussy

# Create Eask-file (leave everything answers empty since it doesn't matter)
$ eask init

# Add sources
$ eask source add melpa      # For everything else
$ eask source add jcs-elpa   # For `flx-rs`

# Installed used packages/dependencies
$ eask install consult flx flx-rs fussy vertico

Then paste the above config to ./.eask/<emacs-version>/init.el

$ eask emacs  # Start Emacs with those packages installed
oscarfv commented 7 months ago

@jcs090218 : is this issue related to flx-rs?

I'm seeing a similar case, but it happens when using vertico + fussy + (flx-rs or plain flx). With ido + flx-ido + flx-rs there is no problem. So it seems that the culprit is not flx-rs itself.

jcs090218 commented 7 months ago

I recently updated the flx-rs; maybe that solves the issue. 🤔 @Eason0210 Can you try with the latest version?

Eason0210 commented 7 months ago

@jcs090218 I tried the latest commit of flx-rs, but the issue is still exist.

oscarfv commented 7 months ago

@jcs090218 : on the issue I've observed there is no difference from the current release of flx-rs to the previous one.

oscarfv commented 7 months ago

Upon further investigation, it seems that I'm misunderstanding what the fussy/emacs combo does.

I have

(setq completion-styles '(fussy))

When switching buffers with vertico (C-x b) as long as the input corresponds to the substring of some candidate, fussy-score is not invoked. Only when the input does not match any candidate as substring, fussy-score is invoked.

For instance, let's say I have these three buffers: parser.cpp parser.h prelude.cpp do-process.cpp. If the input is p, only those that start with that letter are listed, do-process.cpp is excluded. If the input is pr, only prelude.cpp is listed. If then the input is prc, then fussy-score is invoked and all the candidates are listed again.

I find this behavior very confusing. I've looked for some configuration that controls this, but found none. What I'm missing?

It seems that only happens in switch-buffer.

(I also realize that my problem is not the same as the the OP, so apologies to @Eason0210 for hijacking his report.)