aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-10-22 14:07:53 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2026-05-16 00:03:14 +0200
commit1bb06d6529be334c4c16d99f91b027e9f6a148d5 (patch)
treedccb1966f097f610e4c04fc40f2849ca8e74fb3e
parenta230f0ac3fbd0a9540329b7951b1e8f3eda797de (diff)
downloadvis-open-extend-1bb06d6529be334c4c16d99f91b027e9f6a148d5.tar.gz
vis-open-extend-1bb06d6529be334c4c16d99f91b027e9f6a148d5.zip
parse even file names with column or additional colon characters
-rw-r--r--init.lua10
1 files changed, 8 insertions, 2 deletions
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)