Skip to content

Commit bdc2a4e

Browse files
committed
fix: upstream bug (#123)
1 parent 8784eeb commit bdc2a4e

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

lua/bqf/preview/session.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ function PreviewSession:display(pwinid, pbufnr, idx, size, handler)
172172
size = size
173173
}
174174
end
175+
local hasShowedScrollBar = floatwin.showScrollBar
175176
local res = floatwin:display(self.winid, pwinid, self.focusable, self.full, handler, titleOpts)
176177
if res then
177178
if self.enableTitle and self.missingTitle() then
@@ -180,6 +181,14 @@ function PreviewSession:display(pwinid, pbufnr, idx, size, handler)
180181
end
181182
if self.enableScrollBar then
182183
scrollbar:display()
184+
-- TODO
185+
-- upstream bug, can't render terminal correctly if create preview component
186+
-- like scrollbar, clear screen manually.
187+
if hasShowedScrollBar == false and floatwin.showScrollBar == true and utils.has10() and
188+
api.nvim_get_mode().mode == 't' then
189+
-- ^L = 0x0c
190+
api.nvim_feedkeys(('%c'):format(0x0c), 'it', false)
191+
end
183192
end
184193
end
185194
end

lua/bqf/utils.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ M.has09 = (function()
2929
end
3030
end)()
3131

32+
---
33+
---@return fun(): boolean
34+
M.has10 = (function()
35+
local has10
36+
return function()
37+
if has10 == nil then
38+
has10 = fn.has('nvim-0.10') == 1
39+
end
40+
return has10
41+
end
42+
end)()
43+
3244
---@return fun(): boolean
3345
M.isWindows = (function()
3446
local isWin

0 commit comments

Comments
 (0)