From 12eb98edcb560302d6986596b34de087b9f88431 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 16 May 2026 00:08:13 +0200 Subject: simplify setting the cursor position by using vis' file:pos_by_linecol --- init.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 6268d59..9799bb2 100644 --- a/init.lua +++ b/init.lua @@ -25,12 +25,10 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- fire a new WIN_OPEN event because we changed the file vis.events.emit(vis.events.WIN_OPEN, win) - -- After the other handlers ran we set the position. - vis:feedkeys(line.."G") - - if column then - vis:feedkeys(tostring(column) .. "l") - end + -- After the other handlers ran we set the position + column = column or 1 + local pos = win.file:pos_by_linecol(line, column) + vis.win.selection.pos = pos -- Stop handling the old FILE_OPEN event since we changed the file and emitted -- a new WIN_OPEN event -- cgit v1.2.3