ctrlp.vim icon indicating copy to clipboard operation
ctrlp.vim copied to clipboard

Search ranking issue: more complete match ranked lower

Open eldamir opened this issue 10 years ago • 23 comments

I have classes

  • InvoiceDetailView
  • TestInvoiceDetailView

When I search tags through ctrlp with "InvoiceDetail", then TestInvoiceDetailView is ranked higher than InvoiceDetailView. That is not what I would have expected. I see two arguments why it should be the other way around:

  1. Search term matches the start if InvoiceDetailView and not TestInvoiceDetailView
  2. Search term covers a larger part of the matched string InvoiceDetailView than TestInvoiceDetailView and is therefor a closer match

Am I missing some configuration, or is the ranking done in some other way, that I was not expecting?

(On a side note: I love this plugin. Couldn't do without it!)

eldamir avatar Dec 18 '15 12:12 eldamir

@eldamir let me have a try

wsdjeg avatar Dec 18 '15 12:12 wsdjeg

It seems to be true of any (Python) classes where I have an identical class name with a prefix of "Test". It always displays the test class first

eldamir avatar Dec 18 '15 12:12 eldamir

2015-12-18 20-34-38

it seem works well for me ,if i type into InvoiceDetail my cursor is located on InvoiceDetailView,java

wsdjeg avatar Dec 18 '15 12:12 wsdjeg

ok let me try will py

wsdjeg avatar Dec 18 '15 12:12 wsdjeg

When I start seaching, initially, the test won't show up:

not_listed

As I type, it shows up

now_listed

And keeps getting ranked first

still_listed

Admittedly, a ton of classes contain the word "Invoice", but "InvoiceDetail" is specific to just those two

eldamir avatar Dec 18 '15 12:12 eldamir

also works well ,you could see my cursor on InvoiceDetailView.py 2015-12-18 20-37-09

wsdjeg avatar Dec 18 '15 12:12 wsdjeg

how do you set g:ctrlp_custom_ignore and your match

wsdjeg avatar Dec 18 '15 12:12 wsdjeg

maybe the path to the file matters? Mine are

/home/ruben/workspace/v3/web/views/invoice.py::InvoiceDetailView /home/ruben/workspace/v3/web/tests/test_invoices.py::TestInvoiceDetail

eldamir avatar Dec 18 '15 12:12 eldamir

can you show me you vimrc ,if possible,

wsdjeg avatar Dec 18 '15 12:12 wsdjeg

my ctrlp specific configs are

if executable('ag')                                                                                                                                   
  " Use ag over grep                                                                                                                                  
  set grepprg=ag\ --nogroup\ --nocolor                                                                                                                

  " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore                                                                         
  let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'                                                                                               

  " ag is fast enough that CtrlP doesn't need to cache                                                                                                
  let g:ctrlp_use_caching = 0                                                                                                                         
endif

set runtimepath^=~/.vim/bundle/ctrlp.vim                                                                                                              
let g:ctrlp_custom_ignore = {                                                                                                                         
  \ 'dir':  '\v[\/](\.git|node_modules|\.sass-cache|bower_components|build|media|__pycache__)$',                                                      
  \ 'file': '\v\.(exe|so|dll|pyc)$',                                                                                                                  
  \ 'link': 'some_bad_symbolic_links',                                                                                                                
  \ }  

Though commenting them away doesn't change the result

eldamir avatar Dec 18 '15 12:12 eldamir

NeoBundle 'FelikZ/ctrlp-py-matcher'

let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch'  }

can you try to use this matcher?

i just use your setting but can not reproduce,the diff is my matcher

and i am using ag -i instead of ag -l

wsdjeg avatar Dec 18 '15 12:12 wsdjeg

same result, although coloured differently

same_result

eldamir avatar Dec 18 '15 12:12 eldamir

here is my ctrlp setting

NeoBundle 'ctrlpvim/ctrlp.vim'
NeoBundle 'FelikZ/ctrlp-py-matcher'
    let g:ctrlp_map = '<c-p>'
    let g:ctrlp_cmd = 'CtrlP'
    let g:ctrlp_working_path_mode = 'ra'
    let g:ctrlp_root_markers = 'pom.xml'
    let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:25,results:25'
    let g:ctrlp_show_hidden = 1
    "for caching
    let g:ctrlp_use_caching = 1
    let g:ctrlp_clear_cache_on_exit = 0
    let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
    "let g:ctrlp_map = ',,'
    "let g:ctrlp_open_multiple_files = 'v'
    set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.class,tags
    let g:ctrlp_custom_ignore = {
                \ 'dir':  '\v[\/]\.(git|hg|svn)$|target',
                \ 'file': '\v\.(exe|so|dll|ttf|png)$',
                \ 'link': 'some_bad_symbolic_links',
                \ }
    let g:ctrlp_user_command = ['ag %s -i --nocolor --nogroup --hidden
                \ --ignore out
                \ --ignore .git
                \ --ignore .svn
                \ --ignore .hg
                \ --ignore .DS_Store
                \ --ignore "**/*.pyc"
                \ -g ""'
                \ ]

    let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch'  }

wsdjeg avatar Dec 18 '15 13:12 wsdjeg

yelds Variable type mismatch for: g:ctrlp_user_command for me

eldamir avatar Dec 18 '15 13:12 eldamir

vim variable should not be defind in diff type ,you can comment you setting for g:ctrlp_user_command

it is due to i am using a list as it's value

wsdjeg avatar Dec 18 '15 13:12 wsdjeg

I don't understand. Would you mind giving me an example I can just paste to my vimrc?

eldamir avatar Dec 18 '15 13:12 eldamir

ok do you using neobundle?

wsdjeg avatar Dec 18 '15 13:12 wsdjeg

I use vundle

eldamir avatar Dec 18 '15 13:12 eldamir

set nocompatible
syntax on
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'FelikZ/ctrlp-py-matcher'
    let g:ctrlp_map = '<c-p>'
    let g:ctrlp_cmd = 'CtrlP'
    let g:ctrlp_working_path_mode = 'ra'
    let g:ctrlp_root_markers = 'pom.xml'
    let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:25,results:25'
    let g:ctrlp_show_hidden = 1
    "for caching
    let g:ctrlp_use_caching = 1
    let g:ctrlp_clear_cache_on_exit = 0
    let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
    "let g:ctrlp_map = ',,'
    "let g:ctrlp_open_multiple_files = 'v'
    set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.class,tags
    let g:ctrlp_custom_ignore = {
                \ 'dir':  '\v[\/]\.(git|hg|svn)$|target',
                \ 'file': '\v\.(exe|so|dll|ttf|png)$',
                \ 'link': 'some_bad_symbolic_links',
                \ }
    let g:ctrlp_user_command = ['ag %s -i --nocolor --nogroup --hidden
                \ --ignore out
                \ --ignore .git
                \ --ignore .svn
                \ --ignore .hg
                \ --ignore .DS_Store
                \ --ignore "**/*.pyc"
                \ -g ""'
                \ ]

    let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch'  }
call vundle#end()
filetype plugin indent on

wsdjeg avatar Dec 18 '15 13:12 wsdjeg

same error :frowning:

eldamir avatar Dec 18 '15 13:12 eldamir

but why? it works well for me ,i have just use this script without anything others.

maybe it is better copy this class into ~/Test/ and try again

wsdjeg avatar Dec 18 '15 13:12 wsdjeg

Hmm.. I'll give it a shot at a later time. My head is swimming at the moment. Thanks for your quick response and suggestions :+1:

eldamir avatar Dec 18 '15 13:12 eldamir

welcome,also it is better use this active fore https://github.com/ctrlpvim/ctrlp.vim

wsdjeg avatar Dec 18 '15 13:12 wsdjeg