feat: add support for bufnr in column rendering functions (#575)
This is primarily for user-defined custom columns, which may want access to the current path or similar information
This commit is contained in:
parent
abbfbd0dbc
commit
8abc58b038
2 changed files with 5 additions and 4 deletions
|
|
@ -12,7 +12,7 @@ local all_columns = {}
|
|||
---@alias oil.ColumnSpec string|{[1]: string, [string]: any}
|
||||
|
||||
---@class (exact) oil.ColumnDefinition
|
||||
---@field render fun(entry: oil.InternalEntry, conf: nil|table): nil|oil.TextChunk
|
||||
---@field render fun(entry: oil.InternalEntry, conf: nil|table, bufnr: integer): nil|oil.TextChunk
|
||||
---@field parse fun(line: string, conf: nil|table): nil|string, nil|string
|
||||
---@field compare? fun(entry: oil.InternalEntry, parsed_value: any): boolean
|
||||
---@field render_action? fun(action: oil.ChangeAction): string
|
||||
|
|
@ -60,8 +60,9 @@ M.EMPTY = EMPTY
|
|||
---@param adapter oil.Adapter
|
||||
---@param col_def oil.ColumnSpec
|
||||
---@param entry oil.InternalEntry
|
||||
---@param bufnr integer
|
||||
---@return oil.TextChunk
|
||||
M.render_col = function(adapter, col_def, entry)
|
||||
M.render_col = function(adapter, col_def, entry, bufnr)
|
||||
local name, conf = util.split_config(col_def)
|
||||
local column = M.get_column(adapter, name)
|
||||
if not column then
|
||||
|
|
@ -69,7 +70,7 @@ M.render_col = function(adapter, col_def, entry)
|
|||
return EMPTY
|
||||
end
|
||||
|
||||
local chunk = column.render(entry, conf)
|
||||
local chunk = column.render(entry, conf, bufnr)
|
||||
if type(chunk) == "table" then
|
||||
if chunk[1]:match("^%s*$") then
|
||||
return EMPTY
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue