@@ -24,11 +24,11 @@ function M.setup()
2424 -- Window resizing is not buffer specific so is managed more globablly
2525 vim .api .nvim_create_autocmd (' WinResized' , {
2626 group = M .group ,
27- callback = function ()
27+ callback = function (args )
2828 for _ , win in ipairs (vim .v .event .windows ) do
2929 local buf = vim .fn .winbufnr (win )
3030 if vim .tbl_contains (buffers , buf ) then
31- ui .debounce_update (buf , win , true )
31+ ui .debounce_update (buf , win , args . event , true )
3232 end
3333 end
3434 end ,
@@ -46,7 +46,7 @@ function M.set_all(enabled)
4646 M .attach (vim .api .nvim_get_current_buf ())
4747 state .enabled = enabled
4848 for _ , buf in ipairs (buffers ) do
49- ui .debounce_update (buf , vim .fn .bufwinid (buf ), true )
49+ ui .debounce_update (buf , vim .fn .bufwinid (buf ), ' UserCommand ' , true )
5050 end
5151end
5252
@@ -67,9 +67,9 @@ function M.attach(buf)
6767 group = M .group ,
6868 buffer = buf ,
6969 callback = function (args )
70- local win = vim .api .nvim_get_current_win ()
70+ local event , win = args . event , vim .api .nvim_get_current_win ()
7171 if buf == vim .fn .winbufnr (win ) then
72- ui .debounce_update (buf , win , vim .tbl_contains (change_events , args . event ))
72+ ui .debounce_update (buf , win , event , vim .tbl_contains (change_events , event ))
7373 end
7474 end ,
7575 })
8080--- @return boolean
8181function M .should_attach (buf )
8282 local file = vim .api .nvim_buf_get_name (buf )
83- local log_name = ' attach ' .. vim .fn .fnamemodify (file , ' :t' )
84- log .debug (log_name , ' start' )
83+ local log_name = string.format ( ' attach %s ' , vim .fn .fnamemodify (file , ' :t' ) )
84+ log .debug_buf (log_name , buf , ' start' )
8585
8686 if vim .tbl_contains (buffers , buf ) then
87- log .debug (log_name , ' skip' , ' already attached' )
87+ log .debug_buf (log_name , buf , ' skip' , ' already attached' )
8888 return false
8989 end
9090
9191 local file_type , file_types = util .get_buf (buf , ' filetype' ), state .file_types
9292 if not vim .tbl_contains (file_types , file_type ) then
93- log .debug (log_name , ' skip' , ' file type' , string.format (' %s /∈ %s' , file_type , vim .inspect (file_types )))
93+ local reason = string.format (' %s /∈ %s' , file_type , vim .inspect (file_types ))
94+ log .debug_buf (log_name , buf , ' skip' , ' file type' , reason )
9495 return false
9596 end
9697
9798 local config = state .get_config (buf )
9899 if not config .enabled then
99- log .debug (log_name , ' skip' , ' state disabled' )
100+ log .debug_buf (log_name , buf , ' skip' , ' state disabled' )
100101 return false
101102 end
102103
103104 local file_size , max_file_size = util .file_size_mb (file ), config .max_file_size
104105 if file_size > max_file_size then
105- log .debug (log_name , ' skip' , ' file size' , string.format (' %f > %f' , file_size , max_file_size ))
106+ local reason = string.format (' %f > %f' , file_size , max_file_size )
107+ log .debug_buf (log_name , buf , ' skip' , ' file size' , reason )
106108 return false
107109 end
108110
109- log .debug (log_name , ' success' )
111+ log .debug_buf (log_name , buf , ' success' )
110112 table.insert (buffers , buf )
111113 return true
112114end
0 commit comments