Skip to content

Commit

Permalink
feat: picker support for dynamic chat names
Browse files Browse the repository at this point in the history
  • Loading branch information
Robitx committed Aug 17, 2024
1 parent 642469b commit 3e90e3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 10 additions & 1 deletion lua/gp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1312,13 +1312,22 @@ M.cmd.ChatFinder = function()
return
end

table.sort(results, function(a, b)
local af = a.file:sub(-24, -11)
local bf = b.file:sub(-24, -11)
if af == bf then
return a.lnum < b.lnum
end
return af > bf
end)

picker_files = {}
preview_lines = {}
local picker_lines = {}
for _, f in ipairs(results) do
if f.line:len() > 0 then
table.insert(picker_files, dir .. "/" .. f.file)
local fline = string.format("%s:%s %s", f.file:sub(3, -11), f.lnum, f.line)
local fline = string.format("%s:%s %s", f.file:sub(-24, -11), f.lnum, f.line)
table.insert(picker_lines, fline)
table.insert(preview_lines, tonumber(f.lnum))
end
Expand Down
7 changes: 0 additions & 7 deletions lua/gp/tasker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,6 @@ M.grep_directory = function(buf, directory, pattern, callback)
})
end
end
table.sort(results, function(a, b)
if a.file == b.file then
return a.lnum < b.lnum
else
return a.file > b.file
end
end)
callback(results, re)
end)
end
Expand Down

0 comments on commit 3e90e3d

Please sign in to comment.