diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/method/textDocument/completion.lua | 8 | ||||
-rw-r--r-- | server/src/parser/lines.lua | 4 | ||||
-rw-r--r-- | server/test/completion/init.lua | 10 |
3 files changed, 10 insertions, 12 deletions
diff --git a/server/src/method/textDocument/completion.lua b/server/src/method/textDocument/completion.lua index 2e084a87..fd5d1ed6 100644 --- a/server/src/method/textDocument/completion.lua +++ b/server/src/method/textDocument/completion.lua @@ -18,7 +18,7 @@ end local function findStartPos(pos, buf) local res = nil - for i = pos-1, 1, -1 do + for i = pos, 1, -1 do local c = buf:sub(i, i) if c:find '[%w_]' then res = i @@ -27,9 +27,9 @@ local function findStartPos(pos, buf) end end if not res then - for i = pos-1, 1, -1 do + for i = pos, 1, -1 do local c = buf:sub(i, i) - if c:find '[%.%:]' then + if c == '.' or c == ':' then res = i elseif c:find '[%s%c]' then else @@ -45,7 +45,7 @@ end local function findWord(position, text) local word = text - for i = position-1, 1, -1 do + for i = position, 1, -1 do local c = text:sub(i, i) if not c:find '[%w_]' then word = text:sub(i+1, position) diff --git a/server/src/parser/lines.lua b/server/src/parser/lines.lua index ddb3e0b3..95e92573 100644 --- a/server/src/parser/lines.lua +++ b/server/src/parser/lines.lua @@ -102,13 +102,11 @@ local function isCharByte(byte) end function mt:positionAsChar(row, col, code) - local pos = self:position(row, col+1, code) + local pos = self:position(row, col, code) if isCharByte(self.buf:byte(pos, pos)) then return pos elseif isCharByte(self.buf:byte(pos+1, pos+1)) then return pos + 1 - elseif isCharByte(self.buf:byte(pos-1, pos-1)) then - return pos - 1 end return pos end diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua index 14c14476..962befa0 100644 --- a/server/test/completion/init.lua +++ b/server/test/completion/init.lua @@ -60,7 +60,7 @@ end local function findStartPos(pos, buf) local res = nil - for i = pos-1, 1, -1 do + for i = pos, 1, -1 do local c = buf:sub(i, i) if c:find '[%w_]' then res = i @@ -69,9 +69,9 @@ local function findStartPos(pos, buf) end end if not res then - for i = pos-1, 1, -1 do + for i = pos, 1, -1 do local c = buf:sub(i, i) - if c:find '[%.%:]' then + if c == '.' or c == ':' then res = i elseif c:find '[%s%c]' then else @@ -87,7 +87,7 @@ end local function findWord(position, text) local word = text - for i = position-1, 1, -1 do + for i = position, 1, -1 do local c = text:sub(i, i) if not c:find '[%w_]' then word = text:sub(i+1, position) @@ -101,7 +101,7 @@ rawset(_G, 'TEST', true) function TEST(script) return function (expect) - local pos = script:find('@', 1, true) + local pos = script:find('@', 1, true) - 1 local new_script = script:gsub('@', ' ') local ast = parser:ast(new_script) local vm = buildVM(ast) |