Skip to content

Commit

Permalink
hoge
Browse files Browse the repository at this point in the history
  • Loading branch information
delphinus committed Nov 23, 2024
1 parent 7ad52ac commit 869d396
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions lua/frecency/entry_maker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,17 @@ function EntryMaker:create(filepath_formatter, workspaces, workspace_tag)
---@param entry FrecencyEntry
---@return table
display = function(entry)
local items = self:items(entry, workspace, workspace_tag, filepath_formatter(workspace))
---@type string
local matched
if workspaces then
for _, workspace in ipairs(workspaces) do
if entry.name:find(workspace, 1, true) then
matched = workspace
break
end
end
end
local items = self:items(entry, matched, workspace_tag, filepath_formatter(matched))
return displayer(items)
end,
}
Expand Down Expand Up @@ -150,16 +160,21 @@ end
---@param workspace_tag string
---@return integer
function EntryMaker:calculate_filter_column_width(workspaces, workspace_tag)
if self:should_show_tail(workspace_tag) then
return #(utils.path_tail(workspace)) + 1
---@type string
local longest
for _, workspace in ipairs(workspaces) do
if not longest or #workspace > #longest then
longest = workspace
end
end
return #(fs.relative_from_home(workspace)) + 1
return self:should_show_tail(workspace_tag) and #(utils.path_tail(longest)) + 1
or #(fs.relative_from_home(longest)) + 1
end

---@private
---@param workspace_tag string
---@return boolean
function EntryMaker:should_show_tail(workspace_tag)
function EntryMaker.should_show_tail(_, workspace_tag)
local show_filter_column = config.show_filter_column
local filters = type(show_filter_column) == "table" and show_filter_column or { "LSP", "CWD" }
return vim.tbl_contains(filters, workspace_tag)
Expand Down

0 comments on commit 869d396

Please sign in to comment.