fix: rg invert and files-with-matches res line parsing (#2208)

This commit is contained in:
Simon Hauser
2022-10-25 21:22:17 +02:00
committed by GitHub
parent 5c7db4055d
commit 9cf465894a
2 changed files with 49 additions and 10 deletions

View File

@@ -244,12 +244,23 @@ do
return { filename, lnum, nil, text }
end
local parse_only_filename = function(t)
t.filename = t.value
t.lnum = nil
t.col = nil
t.text = ""
return { t.filename, nil, nil, "" }
end
function make_entry.gen_from_vimgrep(opts)
opts = opts or {}
local mt_vimgrep_entry
local parse = parse_with_col
if opts.__inverted == true then
if opts.__matches == true then
parse = parse_only_filename
elseif opts.__inverted == true then
parse = parse_without_col
end
@@ -290,7 +301,7 @@ do
end
end
local display_string = "%s:%s%s"
local display_string = "%s%s%s"
mt_vimgrep_entry = {
cwd = vim.fn.expand(opts.cwd or vim.loop.cwd()),
@@ -300,10 +311,12 @@ do
local coordinates = ""
if not disable_coordinates then
if entry.col then
coordinates = string.format("%s:%s:", entry.lnum, entry.col)
else
coordinates = string.format("%s:", entry.lnum)
if entry.lnum then
if entry.col then
coordinates = string.format(":%s:%s:", entry.lnum, entry.col)
else
coordinates = string.format(":%s:", entry.lnum)
end
end
end