aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorgi Kirilov <in.the@repo>2020-05-19 22:28:18 +0300
committerGeorgi Kirilov <in.the@repo>2020-05-20 19:26:06 +0300
commitd8b1d482541cc05d3ff664a2ba352daf3d2960ac (patch)
tree2231872b31b1e9d4f84c8955c2670a1d07a9abc8
parent07761cf7987ede340b0285357d21b7226009699a (diff)
downloadvis-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.
-rw-r--r--defaults.lua4
-rw-r--r--init.lua8
2 files changed, 7 insertions, 5 deletions
diff --git a/defaults.lua b/defaults.lua
index 5c634b3..b754516 100644
--- a/defaults.lua
+++ b/defaults.lua
@@ -1,11 +1,13 @@
return {
{"absolute", "relative"},
+ {"upper", "lower"},
+ {"up", "down"},
{"high", "low"},
{"horizontal", "vertical"},
+ {"inner", "outer"},
{"in", "out"},
{"left", "right"},
{"top", "bottom"},
- {"up", "down"},
{"black", "white"},
{"gray", "maroon", "red", "purple", "fuchsia", "green", "yellow", "blue", "aqua"},
diff --git a/init.lua b/init.lua
index b9e336a..5e5b86b 100644
--- a/init.lua
+++ b/init.lua
@@ -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