diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/files.lua | 4 | ||||
-rw-r--r-- | script/proto/converter.lua | 24 | ||||
-rw-r--r-- | script/provider/diagnostic.lua | 2 |
3 files changed, 17 insertions, 13 deletions
diff --git a/script/files.lua b/script/files.lua index dc39a446..19f4da89 100644 --- a/script/files.lua +++ b/script/files.lua @@ -518,8 +518,8 @@ function m.getVisibles(uri) end local visibles = {} for i, range in ipairs(ranges) do - local startRow = guide.rowColOf(range.start) - local finishRow = guide.rowColOf(range['end']) + local startRow = range.start.line + local finishRow = range['end'].line visibles[i] = { start = guide.positionOf(startRow, 0), finish = guide.positionOf(finishRow, 0), diff --git a/script/proto/converter.lua b/script/proto/converter.lua index d2be23d2..9ff7e4dd 100644 --- a/script/proto/converter.lua +++ b/script/proto/converter.lua @@ -11,11 +11,13 @@ local m = {} ---@return position function m.packPosition(uri, pos) local row, col = guide.rowColOf(pos) - local state = files.getState(uri) - local text = files.getText(uri) - if text then - local lineOffset = state.lines[row] - col = utf8.len(text, lineOffset, lineOffset + col - 1, true) + if col > 0 then + local state = files.getState(uri) + local text = files.getText(uri) + if text then + local lineOffset = state.lines[row] + col = utf8.len(text, lineOffset, lineOffset + col - 1, true) + end end return { line = row, @@ -28,11 +30,13 @@ end ---@return integer function m.unpackPosition(uri, position) local row, col = position.line, position.character - local state = files.getState(uri) - local text = files.getText(uri) - if text then - local lineOffset = state.lines[row] - col = utf8.offset(text, lineOffset + col, lineOffset) - 1 + if col > 0 then + local state = files.getState(uri) + local text = files.getText(uri) + if text then + local lineOffset = state.lines[row] + col = utf8.offset(text, col + 1, lineOffset) - 1 + end end local pos = guide.positionOf(row, col) return pos diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 37c25cf9..382b73d9 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -46,7 +46,7 @@ local function buildSyntaxError(uri, err) else rmessage = text:sub(rel.start, rel.finish) end - local relUri = rel.uri + local relUri = rel.uri or uri relatedInformation[#relatedInformation+1] = { message = rmessage, location = converter.location(relUri, converter.packRange(relUri, rel.start, rel.finish)), |