diff options
author | Georgi Kirilov <in.the@repo> | 2020-05-19 22:28:18 +0300 |
---|---|---|
committer | Georgi Kirilov <in.the@repo> | 2020-05-20 19:26:06 +0300 |
commit | d8b1d482541cc05d3ff664a2ba352daf3d2960ac (patch) | |
tree | 2231872b31b1e9d4f84c8955c2670a1d07a9abc8 /init.lua | |
parent | 07761cf7987ede340b0285357d21b7226009699a (diff) | |
download | vis-toggler-d8b1d482541cc05d3ff664a2ba352daf3d2960ac.tar.gz |
don't inc/dec words _after_ the cursor
some short words that are part of larger words are very easy to
toggle by mistake. Only do "lookahead" for numbers.
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -23,9 +23,9 @@ local count local char_next = 17 -local function at_or_after(_, _, pos, start, finish) +local function at_or_after(_, _, pos, start, finish, is_number) if start and finish then - if pos >= start and pos < finish or pos < start then + if pos >= start and pos < finish or is_number and pos < start then return true, start, finish end end @@ -38,8 +38,8 @@ local function ordinal(win, pos) end local line = win.file.lines[selection.line] local dec_num = P"-"^-1 * R"09"^1 - local patt = dec_num + ordinal_words - local start, finish = P{Cmt(Cc(selection.col) * Cp() * patt * Cp(), at_or_after) + 1 * V(1)}:match(line) + local patt = Cp() * dec_num * Cp() * Cc(true) + Cp() * ordinal_words * Cp() + local start, finish = P{Cmt(Cc(selection.col) * patt, at_or_after) + 1 * V(1)}:match(line) if not (start and finish) then return end local line_begin = selection.pos - selection.col + 1 return line_begin + start - 1, line_begin + finish - 1 |