From 9cd911814b6cdc961a50894ed95bb440efb8eda4 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 24 Nov 2015 14:47:50 +0000 Subject: 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. --- lib/lace/lex.lua | 4 ++++ 1 file changed, 4 insertions(+) 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 -- cgit v1.2.1