Skip to content

Commit

Permalink
feat(path_display): support filename_first
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestrew committed Jul 10, 2024
1 parent f4504dc commit bd81409
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lua/telescope/_extensions/file_browser/make_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ local make_entry = function(opts)
local display_array = {}
local icon, icon_hl

local tail = fb_utils.sanitize_path_str(entry.ordinal)
local path_display = utils.transform_path(opts, tail)
local path_display, style =
utils.create_path_display(entry, vim.tbl_extend("force", opts, { disable_devicons = true }))

if entry.is_dir then
if entry.path == parent_dir then
path_display = ".."
path_display = "../"
end
path_display = path_display .. os_sep
end

if not opts.disable_devicons then
Expand Down Expand Up @@ -162,7 +161,12 @@ local make_entry = function(opts)
if #path_display > file_width then
path_display = strings.truncate(path_display, file_width, nil, -1)
end
local display = entry.is_dir and { path_display, "TelescopePreviewDirectory" } or path_display
local display = {
path_display,
function()
return style
end,
}
table.insert(display_array, entry.stat and display or { display, "WarningMsg" })
table.insert(widths, { width = file_width })

Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/_extensions/file_browser/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ end
---@return string
fb_utils.sanitize_path_str = function(path)
path = path:gsub(os_sep .. os_sep, os_sep)
if iswin then
if fb_utils.iswin then
if path:match "^%w:\\$" then
return path
else
Expand Down

0 comments on commit bd81409

Please sign in to comment.