@@ -79,21 +79,21 @@ M.set_winopt = function(opt, winid)
7979 config .winopt (opt , winid )
8080end
8181
82- --- @param winid integer
82+ --- @param mwinid integer
8383--- @param row integer
84- local function set_current_line_by_percentage (winid , row )
85- local win_h = M .win_get_true_height (winid )
86- local bufnr = api .nvim_win_get_buf (winid )
84+ local function set_current_line_by_percentage (mwinid , row )
85+ local win_h = M .win_get_true_height (mwinid )
86+ local bufnr = api .nvim_win_get_buf (mwinid )
8787 local line_cnt = api .nvim_buf_line_count (bufnr )
8888 local topline = math.floor (row - (row * win_h ) / line_cnt ) + 1
8989 row = math.max (1 , math.min (row , line_cnt ))
9090 topline = math.max (1 , math.min (topline , line_cnt ))
91- return function ()
91+ api . nvim_win_call ( mwinid , function ()
9292 local view = vim .fn .winsaveview ()
9393 view .topline = topline
9494 view .lnum = row
9595 vim .fn .winrestview (view )
96- end
96+ end )
9797end
9898
9999--- @param swinid integer
@@ -156,13 +156,13 @@ M.sync_to_source = function(swinid, mwinid)
156156 if row <= line_cnt then
157157 local util = require (" neominimap.util" )
158158 vim .schedule (function ()
159- local ok = util .noautocmd (pcall )(( function ()
159+ local ok = util .noautocmd (function ()
160160 if config .current_line_position == " center" then
161- return vim .api .nvim_win_set_cursor , mwinid , { row , 0 }
161+ return pcall ( vim .api .nvim_win_set_cursor , mwinid , { row , 0 })
162162 else
163- return api . nvim_win_call , mwinid , set_current_line_by_percentage ( mwinid , row )
163+ return pcall ( set_current_line_by_percentage , mwinid , row )
164164 end
165- end )())
165+ end )()
166166 if not ok then
167167 logger .log .error (" Failed to set cursor" )
168168 end
0 commit comments