@@ -6,7 +6,7 @@ local log = require "nvim-tree.log"
6
6
7
7
local DEFAULT_MIN_WIDTH = 30
8
8
local DEFAULT_MAX_WIDTH = - 1
9
- local DEFAULT_PADDING = 3
9
+ local DEFAULT_PADDING = 1
10
10
11
11
M .View = {
12
12
adaptive_size = false ,
@@ -103,7 +103,6 @@ local function create_buffer(bufnr)
103
103
end
104
104
105
105
local function get_size (size )
106
- size = size or M .View .width
107
106
if type (size ) == " number" then
108
107
return size
109
108
elseif type (size ) == " function" then
@@ -114,6 +113,11 @@ local function get_size(size)
114
113
return math.floor (vim .o .columns * percent_as_decimal )
115
114
end
116
115
116
+ local function get_width (size )
117
+ size = size or M .View .width
118
+ return get_size (size )
119
+ end
120
+
117
121
local move_tbl = {
118
122
left = " H" ,
119
123
right = " L" ,
@@ -250,16 +254,18 @@ end
250
254
local function grow ()
251
255
local starts_at = M .is_root_folder_visible (require (" nvim-tree.core" ).get_cwd ()) and 1 or 0
252
256
local lines = vim .api .nvim_buf_get_lines (M .get_bufnr (), starts_at , - 1 , false )
253
- -- 1 column of right-padding to indicate end of path
254
- local padding = M .View .padding
257
+ -- number of columns of right-padding to indicate end of path
258
+ local padding = get_size (M .View .padding )
259
+ print (padding )
260
+
255
261
local resizing_width = M .View .initial_width - padding
256
262
local max_width
257
263
258
264
-- maybe bound max
259
265
if M .View .max_width == - 1 then
260
266
max_width = - 1
261
267
else
262
- max_width = get_size (M .View .max_width ) - padding
268
+ max_width = get_width (M .View .max_width ) - padding
263
269
end
264
270
265
271
for _ , l in pairs (lines ) do
@@ -311,7 +317,7 @@ function M.resize(size)
311
317
return
312
318
end
313
319
314
- local new_size = get_size ()
320
+ local new_size = get_width ()
315
321
vim .api .nvim_win_set_width (M .get_winnr (), new_size )
316
322
317
323
events ._dispatch_on_tree_resize (new_size )
@@ -524,7 +530,7 @@ function M.setup(opts)
524
530
M .View .width = options .width
525
531
end
526
532
527
- M .View .initial_width = get_size ()
533
+ M .View .initial_width = get_width ()
528
534
end
529
535
530
536
return M
0 commit comments