@@ -630,8 +630,13 @@ function Previewer.base:copy_extmarks()
630630 local dst_bufnr = self .preview_bufnr
631631 local ns = self .ns_extmarks
632632 local win = self .win .preview_winid
633- local topline = fn .line (" w0" , win )
633+ local winview = api .nvim_win_call (win , fn .winsaveview )
634+ local topline = winview .topline
634635 local botline = fn .line (" w$" , win )
636+ local src_winid = fn .bufwinid (src_bufnr )
637+ local src_leftcol = src_winid ~= - 1 and api .nvim_win_call (src_winid , fn .winsaveview ).leftcol or nil
638+ -- virt_text is related to screen https://github.com/neovim/neovim/issues/14050
639+ local no_virt_text = winview .leftcol ~= src_leftcol
635640 api .nvim_buf_clear_namespace (dst_bufnr , ns , topline , botline )
636641 for _ , n in pairs (api .nvim_get_namespaces ()) do
637642 local extmarks = api .nvim_buf_get_extmarks (src_bufnr , n , { topline - 1 , 0 },
@@ -640,6 +645,7 @@ function Previewer.base:copy_extmarks()
640645 for _ , m in ipairs (extmarks ) do
641646 local _ , row , col , details = unpack (m ) --- @cast details -?
642647 details .ns_id = nil
648+ if no_virt_text and details .virt_text then details .virt_text = nil end
643649 pcall (api .nvim_buf_set_extmark , dst_bufnr , ns , row , col , details )
644650 end
645651 end
0 commit comments