summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2015-11-24 14:47:50 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2015-11-24 14:47:50 +0000
commit9cd911814b6cdc961a50894ed95bb440efb8eda4 (patch)
treed8d6f160ecced455a157b05a1d69ea00372a463b
parent4665154a4f1cc63d80f6cb6024cb69b111560779 (diff)
downloadlace-9cd911814b6cdc961a50894ed95bb440efb8eda4.tar.gz
lace.lex: Don't include trailing ] in subword
The trailing ] terminates the word, but is not part of it, so it should not be included in the word's span. It's simpler to fall through the termination with a modified current position than consume the word again.
-rw-r--r--lib/lace/lex.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/lace/lex.lua b/lib/lace/lex.lua
index d7d18da..3bd9ec2 100644
--- a/lib/lace/lex.lua
+++ b/lib/lace/lex.lua
@@ -46,6 +46,10 @@ local function _lex_one_line(line, terminator)
else
if c == terminator and quoting == false then
-- Reached the terminator, break out
+ -- The terminator is not actually part of the last word in the line
+ -- so we push back that character,
+ -- since it's the only case we actually need to put any back.
+ cpos = cpos - 1
break
elseif c == "'" and quoting == false then
-- Start single quotes