From 63b8d2ce0e0fd62833c4d795383411b77673ead6 Mon Sep 17 00:00:00 2001 From: Michiel van den Heuvel Date: Thu, 8 Jun 2023 19:17:52 +0200 Subject: Avoid screen flicker when navigating within file When using vis_open_doc_pos, don't reopen the file if the path of the opened file and the doc_pos match. --- init.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index bcf6099..9125940 100644 --- a/init.lua +++ b/init.lua @@ -299,9 +299,13 @@ local function vis_open_doc_pos(doc_pos, cmd, win) vis.win = win end assert(cmd) - vis:command(string.format('%s \'%s\'', cmd, doc_pos.file)) - vis.win.selection:to(doc_pos.line, doc_pos.col) - vis:command('lspc-open') + if vis.win.file.path ~= doc_pos.file then + vis:command(string.format('%s \'%s\'', cmd, doc_pos.file)) + vis.win.selection:to(doc_pos.line, doc_pos.col) + vis:command('lspc-open') + else + vis.win.selection:to(doc_pos.line, doc_pos.col) + end end -- Support jumping between document positions -- cgit v1.2.3