@ 261105.2

250910.13 · 95d1aad6d0a08c95f760f63aac8af3f68cd9496e

fix: remove redundant space in rg cmd args

fix: trim empty -iglob args

reading declarations

lua/fzf-lua/make_entry.lua

@@ -135,7 +135,9 @@ M.glob_parse = function(query, opts)   local glob_args = ""   local search_query, glob_str = query:match("(.*)" .. opts.glob_separator .. "(.*)")   for _, s in ipairs(utils.strsplit(glob_str, "%s+")) do-    glob_args = glob_args .. ("%s %s "):format(opts.glob_flag, libuv.shellescape(s))+    if #s > 0 then+      glob_args = glob_args .. ("%s %s "):format(opts.glob_flag, libuv.shellescape(s))+    end   end   return search_query, glob_args end@@ -156,7 +158,7 @@ M.rg_insert_args = function(cmd, args, relocate_pattern)     -- if pattern was not specified search for `-e<SPACE>` or `-e<EOL>`     if relocate_pattern and #relocate_pattern > 0 then       table.insert(patterns, {-        a[1] .. "%s-" .. relocate_pattern,+        a[1] .. "%s-" .. relocate_pattern .. "%s*",         a[2] .. " " .. relocate_pattern,       })     else@@ -166,11 +168,12 @@ M.rg_insert_args = function(cmd, args, relocate_pattern)   end   -- if pattern was specified also search for `<pattern>` directly   if relocate_pattern and #relocate_pattern > 0 then-    table.insert(patterns, { relocate_pattern, relocate_pattern })+    table.insert(patterns, { "%s+" .. relocate_pattern .. "%s*", relocate_pattern })   end   for _, a in ipairs(patterns) do     if cmd:match(a[1]) then-      return string.format("%s %s %s", cmd:gsub(a[1], " "), args, a[2])+      cmd = cmd:gsub(a[1], " ")+      return string.format("%s %s %s", cmd:gsub("%s+$", ""), args:gsub("%s+$", ""), a[2])     end   end   -- cmd doesn't contain `-e` or `--` or <pattern>, concat args

tests/screenshots/tests-grep_spec.lua---grep---search---regex---1-+-args-{-false-}

@@ -7,8 +7,8 @@ 06|~      │  :: <ctrl-g> to Regex Search, Grep string: \(·· │       07|~      │  [DEBUG] [st] rg --column --line-number --no-he │       08|~      │  ↳ ading --color=always --smart-case --max-colu │      -09|~      │  ↳ mns=4096  --iglob 'tests/grep*'  -e '\(\~'\' │      -10|~      │  ↳ '"\\/\$\?'\''`\*&&\|\|;\[]<>\)'              │      +09|~      │  ↳ mns=4096 --iglob 'tests/grep*' -e '\(\~'\''" │      +10|~      │  ↳ \\/\$\?'\''`\*&&\|\|;\[]<>\)'                │       11|~      │▌  tests/grep_spec.lua:32:21:      search = [== │       12|~      │▌ ↳ =[(~'"\/$?'`*&&||;[]<>) --tests/grep*]===],  │       13|~      │                                                 │      

tests/screenshots/tests-grep_spec.lua---grep---search---regex---1-+-args-{-true-}

@@ -7,8 +7,8 @@ 06|~      │  :: <ctrl-g> to Regex Search, Grep string: \(·· │       07|~      │  [DEBUG] [mt] rg --column --line-number --no-he │       08|~      │  ↳ ading --color=always --smart-case --max-colu │      -09|~      │  ↳ mns=4096  --iglob 'tests/grep*'  -e '\(\~'\' │      -10|~      │  ↳ '"\\/\$\?'\''`\*&&\|\|;\[]<>\)'              │      +09|~      │  ↳ mns=4096 --iglob 'tests/grep*' -e '\(\~'\''" │      +10|~      │  ↳ \\/\$\?'\''`\*&&\|\|;\[]<>\)'                │       11|~      │▌  tests/grep_spec.lua:32:21:      search = [== │       12|~      │▌ ↳ =[(~'"\/$?'`*&&||;[]<>) --tests/grep*]===],  │       13|~      │                                                 │      

tests/utils_spec.lua

@@ -1,5 +1,6 @@ local helpers = require("fzf-lua.test.helpers") local assert = helpers.assert+local eq = assert.are.same  local fzf = require("fzf-lua") local utils = fzf.utils@@ -101,4 +102,18 @@ describe("Testing utils module", function()     assert.are.same(vim.wo[0][0].nu, vim.wo.nu)     assert.are.same(vim.wo[0][0].rnu, vim.wo.rnu)   end)++  it("strsplit", function()+    eq(utils.strsplit("abc", "%s+"), { "abc" })+    eq(utils.strsplit("", "%s+"), { "" })+    eq(utils.strsplit("foo bar baz", "%s+"), { "foo", "bar", "baz" })+    eq(utils.strsplit("foo   bar    baz", "%s+"), { "foo", "bar", "baz" })+    eq(utils.strsplit("foo\tbar\nbaz", "%s+"), { "foo", "bar", "baz" })+    eq(utils.strsplit("  foo bar  ", "%s+"), { "", "foo", "bar", "" })+    eq(utils.strsplit("foo,,bar,,baz", ",+"), { "foo", "bar", "baz" })+    eq(utils.strsplit("a,b,c", ","), { "a", "b", "c" })+    eq(utils.strsplit(",,,", ",+"), { "", "" })+    eq(utils.strsplit(",foo,bar,", ","), { "", "foo", "bar", "" })+    eq(utils.strsplit("foobar", ","), { "foobar" })+  end) end)