summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/files.lua9
-rw-r--r--script/parser/guide.lua2
3 files changed, 4 insertions, 8 deletions
diff --git a/changelog.md b/changelog.md
index 07201f59..0e4c8559 100644
--- a/changelog.md
+++ b/changelog.md
@@ -23,6 +23,7 @@
* `FIX` infer of `---@type class[][]`
* `FIX` infer of `---@type {}[]`
* `FIX` completion: displaying `@fenv` in `Lua 5.1`
+* `FIX` completion: incorrect at end of line
* `FIX` when a file is renamed, the file will still be loaded even if the new file name has been set to ignore
* `FIX` [#596](https://github.com/sumneko/lua-language-server/issues/596)
* `FIX` [#597](https://github.com/sumneko/lua-language-server/issues/597)
diff --git a/script/files.lua b/script/files.lua
index f9023ae2..f6fa337c 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -721,15 +721,10 @@ function m.position(uri, offset, leftOrRight)
line = row - 1,
character = ucol,
}
- elseif col == 1 then
- return {
- line = row - 1,
- character = 0,
- }
else
return {
- line = row,
- character = 0,
+ line = row - 1,
+ character = util.utf8Len(text, start, finish),
}
end
end
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 8d681fdc..a9d832b2 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -698,7 +698,7 @@ function m.positionOf(lines, offset)
end
local lastLine = lines[#lines]
if offset > lastLine.finish then
- return #lines, offset - lastLine.start
+ return #lines, offset - lastLine.start + 1
end
local min = 1
local max = #lines