Hi,

On Wed, Oct 14, 2020 at 1:28 PM Maxim Kim <[email protected]> wrote:

> The plugin I do https://github.com/habamax/vim-select uses ripgrep to
> feed files into fuzzymatchpos function. It looks good for me with one minor
> issue with sorting, have a look into the video I have recorded:
>
> https://youtu.be/RPM3GccvDGA
>
> What is happening there:
>
> 1. I ran `rg --files --no-ignore-vcs --hidden --glob !.git` in a job
> 2. On out_cb handler I update the buffer with the files
> 3. You can see ordering of the same files is constantly changed -- I
> believe it shouldn't be like this, but not 100% sure.
>
> So should the order or sort of the matchfuzzypos result be the same on the
> second, third etc run? The data matchfuzzypos operates on is constantly
> increasing but the output (top) is the same only sorted a bit differently.
>

The matchfuzzy() function uses the standard C library qsort() function to
sort the
matches by score. The qsort() function is not guaranteed to be stable as
explained
in the following page;

https://nullprogram.com/blog/2014/08/29/#:~:text=Since%20quicksort%20is%20an%20unstable,has%20no%20stable%20sort%20function
.

So the list of strings passed to the matchfuzzy() function with the same
matching
score are not guaranteed to retain the same order in the returned list.

Note that if you call the matchfuzzy() function multiple times with
different
number of strings, then their matching scores may be different and the
returned list may have a different order for the strings.

- Yegappan

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7k2UGzXAVc_9oyKBDV6RfMeR-gn%2B2s7H8eFP7yeFSBc3A%40mail.gmail.com.

Raspunde prin e-mail lui