Skip to content

Commit 2e834d3

Browse files
committed
docs: consolidate comments
1 parent a956ea7 commit 2e834d3

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

lua/nvim-tree/renderer/builder.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ end
455455
function Builder.setup(opts)
456456
M.opts = opts
457457

458+
-- Still follows this priorty order
458459
M.decorator_size = DecoratorSize:new(opts)
459-
460460
M.decorators = {
461461
DecoratorCut:new(opts),
462462
DecoratorCopied:new(opts),

lua/nvim-tree/renderer/decorator/size.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ function DecoratorSize:new(opts)
3333
o.column_width = opts.renderer.size.column_width
3434
o.show_folder_size = opts.renderer.size.show_folder_size
3535
o.units = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }
36-
o.format_unit = opts.renderer.size.format_unit -- guaranteed to be a function
36+
37+
-- Guaranteed to be a function from previous setup
38+
o.format_unit = opts.renderer.size.format_unit
3739
o.format_size = function(size)
3840
local formatted = string
3941
.format("%.2f", size)
@@ -51,15 +53,16 @@ end
5153
---@private
5254
---@param size number size in bytes
5355
---@return string
54-
--- edit: Since then I've moved a lot of ifs around getting down to only three, but I'll keep the comment just in case.
56+
--- edit: Since then I've moved a lot of ifs around getting down to only three, but I'll keep the comment bellow just in case.
5557
---NOTE: This function still try it's best to minified the string
56-
--- generated, but this implies that we have more than 3 branchs
58+
--- generated, but this implies that we have some branches
5759
--- to determined how much bytes can we shave from the string to
58-
--- comply to self.column_width. Since we know self.column_width doesn't
59-
--- change, a better way could be to decide a version of 'human_readable_size' based
60-
--- on self.column_width once at this object's construction.
61-
--- Basically, instead of this method, we would baking all ifs first to decide which function to bind to possible field `self.human_readable_size`
62-
--- I don't actually know if it would be faster without test.
60+
--- comply to `self.column_width`.
61+
--- Since we know `self.column_width` doesn't change, a better way could be
62+
--- decide a version of 'human_readable_size' a priori, based
63+
--- on `self.column_width` *once* at this object's construction.
64+
--- Basically, instead of this method, we would "baking" all ifs first
65+
--- to decide which function to bind to possible field `self.human_readable_size`.
6366
function DecoratorSize:human_readable_size(size)
6467
-- Check for nan, negative, etc.
6568
if type(size) ~= "number" or size ~= size or size < 0 then

0 commit comments

Comments
 (0)