Skip to content

Commit 9863339

Browse files
phanenibhagwan
authored andcommitted
fix(previewer): scroll previewer on buffer without ft detected
1 parent a56dfa1 commit 9863339

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lua/fzf-lua/previewer/builtin.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,10 @@ local ts_attach = function(bufnr, ft)
870870
end
871871

872872
function Previewer.base:update_ts_context()
873-
if not self.win
873+
local bufnr = self.preview_bufnr
874+
local ft = vim.b[bufnr] and vim.b[bufnr]._ft
875+
if not ft
876+
or not self.win
874877
or not self.win:validate_preview()
875878
or not self.treesitter.enabled
876879
or not self.treesitter.context
@@ -881,7 +884,7 @@ function Previewer.base:update_ts_context()
881884
-- return empty unless parsing is complete and we have no access to the `on_parse` event
882885
-- https://github.com/neovim/neovim/commit/45e606b1fddbfeee8fe28385b5371ca6f2fba71b
883886
-- For more info see #1922
884-
local lang = vim.treesitter.language.get_lang(vim.b[self.preview_bufnr]._ft)
887+
local lang = vim.treesitter.language.get_lang(ft)
885888
local parser = vim.treesitter.get_parser(self.preview_bufnr, lang)
886889
local context_updated
887890
for _, t in ipairs({ 0, 20, 50, 100 }) do

0 commit comments

Comments
 (0)