Skip to content

Commit

Permalink
fix: view.width functions may return strings (#3020)
Browse files Browse the repository at this point in the history
* Fix get_size() function when size is a function return string

* update view.width help

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
  • Loading branch information
ljie-PI and alex-courtis authored Dec 8, 2024
1 parent 375e386 commit 6b4be1d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -800,22 +800,22 @@ Width of the window: can be a `%` string, a number representing columns, a
function or a table.
A table indicates that the view should be dynamically sized based on the
longest line.
Type: `string | number | table | function()` returning a number
Type: `string | number | table | fun(): number|string`
Default: `30`

*nvim-tree.view.width.min*
Minimum dynamic width.
Type: `string | number | function()` returning a number
Type: `string | number | fun(): number|string`
Default: `30`

*nvim-tree.view.width.max*
Maximum dynamic width, -1 for unbounded.
Type: `string | number | function()` returning a number
Type: `string | number | fun(): number|string`
Default: `-1`

*nvim-tree.view.width.padding*
Extra padding to the right.
Type: `number | function()` returning a number
Type: `number | fun(): number|string`
Default: `1`

*nvim-tree.view.float*
Expand Down
2 changes: 1 addition & 1 deletion lua/nvim-tree/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ local function get_size(size)
if type(size) == "number" then
return size
elseif type(size) == "function" then
return size()
return get_size(size())
end
local size_as_number = tonumber(size:sub(0, -2))
local percent_as_decimal = size_as_number / 100
Expand Down

0 comments on commit 6b4be1d

Please sign in to comment.