antoinemadec / coc-fzf

fzf :heart: coc.nvim
390 stars 28 forks source link

Search results are not sorted by relevance #121

Closed Sangdol closed 2 years ago

Sangdol commented 2 years ago

Hello,

Thanks for the awesome plugin.

Is your feature request related to a problem? Please describe.

I found that search results are not ordered by relevance, unlike how fzf usually works. Instead, they are ordered by the lexicographical order of file paths and names.

For example, when I search Booking in my project, this shows up:

InvalidBookingStateError [Class]:PROJECT_HOME/errors.py:11:6                                                    
BookingAdmin [Class]:PROJECT_HOME/bookings/admin.py:25:6                                                        
BookingState [Class]:PROJECT_HOME/bookings/choices.py:9:6                                                       
BookingSortingParams [Class]:PROJECT_HOME/bookings/customer_api.py:34:6                                         
Booking [Class]:PROJECT_HOME/bookings/models.py:90:6                   <=== Booking is here            
BookingQuerySet [Class]:PROJECT_HOME/bookings/querysets.py:28:6                                                 
_BaseBookingSchema [Class]:PROJECT_HOME/bookings/schemas.py:51:6                                                
BookingSchemaIn [Class]:PROJECT_HOME/bookings/schemas.py:69:6                                                   
BookingEvent [Class]:PROJECT_HOME/bookings/schemas.py:76:6                                                      
BookingSchemaOut [Class]:PROJECT_HOME/bookings/schemas.py:88:6                                                  
BookingStatusSchemaIn [Class]:PROJECT_HOME/bookings/schemas.py:102:6                                            
BookingStatusSchemaOut [Class]:PROJECT_HOME/bookings/schemas.py:106:6

This makes it hard to select the desired result.

Describe the solution you'd like

It would be great if the result shows up in the order of something like this:

Booking [Class]:PROJECT_HOME/bookings/models.py:90:6                                                            
BookingAdmin [Class]:PROJECT_HOME/bookings/admin.py:25:6                                                        
BookingEvent [Class]:PROJECT_HOME/bookings/schemas.py:76:6                                                      
BookingState [Class]:PROJECT_HOME/bookings/choices.py:9:6                                                       
BookingSchemaIn [Class]:PROJECT_HOME/bookings/schemas.py:69:6                                                   
BookingSchemaOut [Class]:PROJECT_HOME/bookings/schemas.py:88:6                                                  
BookingSortingParams [Class]:PROJECT_HOME/bookings/customer_api.py:34:6                                         
BookingStatusSchemaIn [Class]:PROJECT_HOME/bookings/schemas.py:102:6                                            
BookingStatusSchemaOut [Class]:PROJECT_HOME/bookings/schemas.py:106:6
BookingQuerySet [Class]:PROJECT_HOME/bookings/querysets.py:28:6                                                 
_BaseBookingSchema [Class]:PROJECT_HOME/bookings/schemas.py:51:6                                                
InvalidBookingStateError [Class]:PROJECT_HOME/errors.py:11:6                                                    

Thank you.

antoinemadec commented 2 years ago

@Sangdol , got it. PR is welcome !

Sangdol commented 2 years ago

It turned out that we could fix this by just removing the --phony option. https://github.com/antoinemadec/coc-fzf/blob/812b0a47d0c8b066684d75bc6f9ad84627f8579e/autoload/coc_fzf/symbols.vim#L72

You can find a discussion about this here.