aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-05-16 00:08:13 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2026-05-16 00:08:13 +0200
commit12eb98edcb560302d6986596b34de087b9f88431 (patch)
treec47ca9b29c56655bcc89841a0a3b0b44cc5475be
parent1bb06d6529be334c4c16d99f91b027e9f6a148d5 (diff)
downloadvis-open-extend-12eb98edcb560302d6986596b34de087b9f88431.tar.gz
vis-open-extend-12eb98edcb560302d6986596b34de087b9f88431.zip
simplify setting the cursor position by using vis' file:pos_by_linecol
-rw-r--r--init.lua10
1 files changed, 4 insertions, 6 deletions
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