@@ -601,6 +601,33 @@ function Previewer.base:scroll(direction)
601601 self .win :update_preview_scrollbar ()
602602 self :update_render_markdown ()
603603 self :update_ts_context ()
604+ self :copy_extmarks ()
605+ end
606+
607+ -- https://github.com/kevinhwang91/nvim-bqf/blob/b51a37fcd808edafd52511458467c8c9a701ea8d/lua/bqf/preview/extmark.lua#L20
608+ function Previewer .base :copy_extmarks ()
609+ -- copy extmarks from source window to preview window
610+ if not self .win or not self .win :validate_preview () or not self .loaded_entry or not self .loaded_entry .bufnr then return end
611+ self .ns_extmarks = self .ns_extmarks or api .nvim_create_namespace (" fzf-lua.preview.extmarks" )
612+ local src_bufnr = self .loaded_entry .bufnr
613+ local dst_bufnr = self .preview_bufnr
614+ local ns = self .ns_extmarks
615+ local wi = utils .getwininfo (self .win .preview_winid ) --- @cast wi -?
616+ local topline = wi .topline
617+ local botline = wi .botline
618+ for _ , n in pairs (api .nvim_get_namespaces ()) do
619+ local extmarks = api .nvim_buf_get_extmarks (src_bufnr , n , { topline - 1 , 0 },
620+ { botline - 1 , - 1 },
621+ { details = true })
622+ for _ , m in ipairs (extmarks ) do
623+ local _ , row , col , details = unpack (m ) --- @cast details -?
624+ local endRow , endCol = details .end_row , details .end_col
625+ local hlGroup = details .hl_group
626+ local priority = details .priority
627+ pcall (api .nvim_buf_set_extmark , dst_bufnr , ns , row , col ,
628+ { end_row = endRow , end_col = endCol , hl_group = hlGroup , priority = priority })
629+ end
630+ end
604631end
605632
606633function Previewer .base :ts_ctx_toggle ()
0 commit comments