diff options
-rw-r--r-- | init.lua | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -2,20 +2,23 @@ local function get_query() local line = vis.win.selection.line local pos = vis.win.selection.col local str = vis.win.file.lines[line] + local len_str = string.len(str) - local from, to = 0, 0 - while pos > to do - from, to = str:find('[%a_]+[%a%d_]*', to + 1) - if from == nil or from > pos then - return nil - end + local to = str:find('%s', pos) - 1 + if to == nil then to = string.len(str) end + local from = str:reverse():find('%s', len_str - pos + 1) + if from == nil then + from = 1 + else + -- reverse index + from = len_str - from + 2 end - - return string.sub(str, from, to) + return str:sub(from, to) end vis:map(vis.modes.NORMAL, "gx", function() local cur_word = get_query() - print(cur_word) - os.execute("xdg-open " .. cur_word) + -- https://bugs.freedesktop.org/show_bug.cgi?id=103807 x + -- https://www.damejidlo.cz/potrefena-husa-vinohrady + os.execute("xdg-open '" .. cur_word .. "'") end, "Jump to URL") |