@@ -99,12 +99,18 @@ function TSContext.update(winid, bufnr, opts)
99
99
TSContext ._winids [tostring (winid )] = bufnr
100
100
end
101
101
end
102
- if TSContext .is_attached (winid ) == bufnr then
102
+ -- NOTE: when previewer win has border, calling `open` on the same win/buf combo
103
+ -- while using `winopts.previewer.border=none` or "noboder" works correctly, most
104
+ -- likely an upstream issue and we've seen no cooperation from upstream so defer
105
+ -- to the same "hack"
106
+ -- local open_once = false
107
+ local open_once = TSContext .is_attached (winid ) == bufnr
108
+ if open_once then
103
109
open ()
104
110
else
105
111
-- HACK: but the entire nvim-treesitter-context is essentially a hack
106
112
-- https://github.com/ibhagwan/fzf-lua/issues/1552#issuecomment-2525456813
107
- for _ , t in ipairs ({ 0 , 20 }) do
113
+ for _ , t in ipairs ({ 0 , 20 , 50 }) do
108
114
vim .defer_fn (function () open () end , t )
109
115
end
110
116
end
@@ -322,8 +328,7 @@ function Previewer.base:clear_preview_buf(newbuf)
322
328
retbuf = self :get_tmp_buffer ()
323
329
utils .win_set_buf_noautocmd (self .win .preview_winid , retbuf )
324
330
-- redraw the title line and clear the scrollbar
325
- self .win :redraw_preview_border ()
326
- self .win :update_scrollbar (true )
331
+ self .win :update_preview_scrollbar (true )
327
332
end
328
333
-- since our temp buffers have 'bufhidden=wipe' the tmp
329
334
-- buffer will be automatically wiped and 'nvim_buf_is_valid'
@@ -372,10 +377,6 @@ function Previewer.base:display_entry(entry_str)
372
377
local populate_preview_buf = function (entry_str_ )
373
378
if not self .win or not self .win :validate_preview () then return end
374
379
375
- -- redraw the preview border, resets title
376
- -- border scrollbar and border highlights
377
- self .win :redraw_preview_border ()
378
-
379
380
-- specialized previewer populate function
380
381
self :populate_preview_buf (entry_str_ )
381
382
@@ -519,7 +520,7 @@ function Previewer.base:scroll(direction)
519
520
end
520
521
self :update_ts_context ()
521
522
self :update_render_markdown ()
522
- self .win :update_scrollbar ()
523
+ self .win :update_preview_scrollbar ()
523
524
end
524
525
525
526
function Previewer .base :ts_ctx_toggle ()
@@ -1078,31 +1079,29 @@ function Previewer.buffer_or_file:set_cursor_hl(entry)
1078
1079
end )
1079
1080
end
1080
1081
1081
- function Previewer .buffer_or_file :update_border (entry )
1082
- if self .title then
1083
- local filepath = entry .path
1084
- if filepath then
1085
- if filepath :match (" ^%[DEBUG]" ) then
1086
- filepath = " [DEBUG]"
1087
- else
1088
- if self .opts .cwd then
1089
- filepath = path .relative_to (entry .path , self .opts .cwd )
1090
- end
1091
- filepath = path .HOME_to_tilde (filepath )
1082
+ function Previewer .buffer_or_file :update_title (entry )
1083
+ if not self .title then return end
1084
+ local filepath = entry .path
1085
+ if filepath then
1086
+ if filepath :match (" ^%[DEBUG]" ) then
1087
+ filepath = " [DEBUG]"
1088
+ else
1089
+ if self .opts .cwd then
1090
+ filepath = path .relative_to (entry .path , self .opts .cwd )
1092
1091
end
1092
+ filepath = path .HOME_to_tilde (filepath )
1093
1093
end
1094
- local title = filepath or entry .uri or entry .bufname
1095
- -- was transform function defined?
1096
- if self .title_fnamemodify then
1097
- local wincfg = vim .api .nvim_win_get_config (self .win .border_winid )
1098
- title = self .title_fnamemodify (title , wincfg and wincfg .width )
1099
- end
1100
- if entry .bufnr then
1101
- title = string.format (" buf %d: %s" , entry .bufnr , title )
1102
- end
1103
- self .win :update_title (" " .. title .. " " )
1104
1094
end
1105
- self .win :update_scrollbar (entry .no_scrollbar )
1095
+ local title = filepath or entry .uri or entry .bufname
1096
+ -- was transform function defined?
1097
+ if self .title_fnamemodify then
1098
+ local wincfg = vim .api .nvim_win_get_config (self .win .preview_winid )
1099
+ title = self .title_fnamemodify (title , wincfg and wincfg .width )
1100
+ end
1101
+ if entry .bufnr then
1102
+ title = string.format (" buf %d: %s" , entry .bufnr , title )
1103
+ end
1104
+ self .win :update_preview_title (" " .. title .. " " )
1106
1105
end
1107
1106
1108
1107
function Previewer .buffer_or_file :preview_buf_post (entry , min_winopts )
@@ -1127,7 +1126,8 @@ function Previewer.buffer_or_file:preview_buf_post(entry, min_winopts)
1127
1126
end
1128
1127
end
1129
1128
1130
- self :update_border (entry )
1129
+ self :update_title (entry )
1130
+ self .win :update_preview_scrollbar (entry .no_scrollbar )
1131
1131
1132
1132
-- save the loaded entry so we can compare
1133
1133
-- bufnr|path with the next entry. If equal
@@ -1222,7 +1222,7 @@ function Previewer.man_pages:populate_preview_buf(entry_str)
1222
1222
vim .api .nvim_buf_set_lines (tmpbuf , 0 , - 1 , false , output )
1223
1223
vim .bo [tmpbuf ].filetype = self .filetype
1224
1224
self :set_preview_buf (tmpbuf )
1225
- self .win :update_scrollbar ()
1225
+ self .win :update_preview_scrollbar ()
1226
1226
end
1227
1227
1228
1228
Previewer .marks = Previewer .buffer_or_file :extend ()
@@ -1393,7 +1393,7 @@ function Previewer.highlights:populate_preview_buf(entry_str)
1393
1393
self .orig_pos = api .nvim_win_get_cursor (0 )
1394
1394
utils .zz ()
1395
1395
end )
1396
- self .win :update_scrollbar ()
1396
+ self .win :update_preview_scrollbar ()
1397
1397
end
1398
1398
1399
1399
Previewer .quickfix = Previewer .base :extend ()
@@ -1444,8 +1444,8 @@ function Previewer.quickfix:populate_preview_buf(entry_str)
1444
1444
vim .api .nvim_buf_set_lines (self .tmpbuf , 0 , - 1 , false , lines )
1445
1445
vim .bo [self .tmpbuf ].filetype = " qf"
1446
1446
self :set_preview_buf (self .tmpbuf )
1447
- self .win :update_title (string.format (" %s: %s" , nr , qf_list .title ))
1448
- self .win :update_scrollbar ()
1447
+ self .win :update_preview_title (string.format (" %s: %s" , nr , qf_list .title ))
1448
+ self .win :update_preview_scrollbar ()
1449
1449
end
1450
1450
1451
1451
Previewer .autocmds = Previewer .buffer_or_file :extend ()
0 commit comments