nvim-telescope / telescope-fzf-native.nvim

FZF sorter for telescope written in c
1.38k stars 45 forks source link

Question about sorting of results #16

Closed thornomad closed 3 years ago

thornomad commented 3 years ago

Hi there ! Thanks so much for this ! Am trying to get my result sort to be the same between fzf.vim and telescope. If I search for a file by inputting agree type. I am used to seeing these results (with my target file on top). Here is example from fzf.vim and from telescope

fzf.vim

my expected result is at the top

image

let $FZF_DEFAULT_OPTS = '--bind ctrl-a:select-all --layout=reverse  --margin=1,4'

telescope

but in telescope the expected result is farther down (it seems to be a reverse sort of the top hits)

image

current settings

require('telescope').setup{
  defaults = {
    prompt_position = "top",
    sorting_strategy = "ascending",
  },
  extensions = {
    fzf = {
      override_generic_sorter = false, -- override the generic sorter
      override_file_sorter = true,     -- override the file sorter
      case_mode = "smart_case",        -- or "ignore_case" or "respect_case"
                                       -- the default case_mode is "smart_case"
    }
  }
}

require('telescope').load_extension('fzf')

Any help is greatly appreciated in advance! Thank you!

Conni2461 commented 3 years ago

I tried to explain this exactly in this readme section: https://github.com/nvim-telescope/telescope-fzf-native.nvim#disclaimer

All your results have the same result score. (I tested this in fzf) agree and type. will be handled individually and then added together. Thats how space works. argree returns 128 for all results and the same applies for type. (resulting to 256 for all). All i do is calculate the scores and return them to telescope. If they now have all the same result it basis it of of the inital table and that one comes from the file system. You can see this in the sorting after the filename. p comes before r before s before t

There is not much i can do to prevent this. Fzf just fills the list differently than telescope, append at the end if score[i] == score[i-1]. To fix this issue we would need some big changes in telescope core.

Another prompt input would be agreetype. which should return app/graphql/types/agreement_type.rb as highest score because it has the lowest difference between e and t

thornomad commented 3 years ago

Thanks for the detailed reply. I had read that disclaimer but was hoping maybe there was some kind of setting I was missing that would allow me to affect the sort.

Another prompt input would be agreetype. which should return app/graphql/types/agreement_type.rb as highest score because it has the lowest difference between e and t

That tip about not using the space is really helpful. I will have to train my brain to give that a whirl think spaceless. Appreciate it.