romgrk / fzy-lua-native

Luajit FFI bindings to FZY
116 stars 15 forks source link

matching incorrect #25

Closed d-r-a-b closed 1 year ago

d-r-a-b commented 1 year ago

Summary

Plugins reports that "messages" and "mzscheme" are a perfect match.

:= require('fzy-lua-native').positions('messages','mzscheme') gives:

{ 1, 2, 3, 4, 5, 6, 7, 8 }
inf
Press ENTER or type command to continue

Expected behavior

These would not match

Reproduction instructions

Given above, but here is a minimal vimrc as well

minimal vimrc, click to expand ```lua -- set temporary reproroot to remove caching artifacts local reproroot = vim.fn.fnamemodify('/tmp/nvim_repro', ':p') if not vim.fn.glob(reproroot) == '' then print('ERROR, '..reproroot..' already exists. Please make sure there is \ nothing important in '..reproroot..' and then remove it') return end for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do vim.env[('XDG_%s_HOME'):format(name:upper())] = reproroot .. '/' .. name end -- bootstrap lazy local lazypath = vim.fn.stdpath('data') .. '/plugins/lazy.nvim' if not vim.loop.fs_stat(lazypath) then vim.fn.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', lazypath, }) end vim.opt.runtimepath:prepend(lazypath) require('lazy').setup({ { 'romgrk/fzy-lua-native', build = ':execute system("make")', }, }) -- cleanup vim.api.nvim_create_autocmd({'VimLeave'}, { pattern = {'*'}, callback = function(--[[ev--]]) vim.fn.delete(reproroot,'rf') end }) ```

Version info

uname -a: Linux apollo 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 GNU/Linux OS: Windows 11 nvim -v: NVIM v0.9.0 Build type: Release LuaJIT 2.1.0-beta3

romgrk commented 1 year ago

I've updated the readme, this is by design. You must call fzy.has_match(string, needle) before you pass anything to the other functions.

https://github.com/romgrk/fzy-lua-native/blob/2b54614af89cbe4945d57b17167eb8af6def91b0/lua/native.lua#L37