From 1bb06d6529be334c4c16d99f91b027e9f6a148d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Tue, 22 Oct 2024 14:07:53 +0200 Subject: parse even file names with column or additional colon characters --- init.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 3f830cd..6268d59 100644 --- a/init.lua +++ b/init.lua @@ -16,8 +16,8 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) return end - local _, _, path, line = string.find(ref, "^(.+):(%d+)$") - if path == nil or line == nil or line == 1 or not file_exists(path) then + local path, line, column = ref:match("^(.-):(%d+):?(%d*):?$") + if not path or not line or tonumber(line) == 1 or not file_exists(path) then return end @@ -28,8 +28,14 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- After the other handlers ran we set the position. vis:feedkeys(line.."G") + if column then + vis:feedkeys(tostring(column) .. "l") + end + -- Stop handling the old FILE_OPEN event since we changed the file and emitted -- a new WIN_OPEN event + + -- Prevent further WIN_OPEN event handlers from running return true end) -- cgit v1.2.3