summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/core/hover/return.lua4
-rw-r--r--script/core/rename.lua3
-rw-r--r--script/core/signature.lua4
4 files changed, 8 insertions, 4 deletions
diff --git a/changelog.md b/changelog.md
index 2476c817..15d69ff9 100644
--- a/changelog.md
+++ b/changelog.md
@@ -23,6 +23,7 @@
local n2 = f(0) -- `n2` is `number`
local n3 = f(0, 0) -- `n3` is `string`
```
+* `FIX` diagnostics flash when opening a file
* `FIX` [#1228](https://github.com/sumneko/lua-language-server/issues/1228)
## 3.3.1
diff --git a/script/core/hover/return.lua b/script/core/hover/return.lua
index 2ee234b6..7f96b282 100644
--- a/script/core/hover/return.lua
+++ b/script/core/hover/return.lua
@@ -64,10 +64,10 @@ local function asFunction(source)
local rtn = vm.getReturnOfFunction(source, i)
local doc = docs[i]
local name = doc and doc.name and doc.name[1] and (doc.name[1] .. ': ')
- local text = ('%s%s'):format(
+ local text = rtn and ('%s%s'):format(
name or '',
vm.getInfer(rtn):view(guide.getUri(source))
- )
+ ) or 'unknown'
if i == 1 then
returns[i] = (' -> %s'):format(text)
else
diff --git a/script/core/rename.lua b/script/core/rename.lua
index 85cbab52..5ba93684 100644
--- a/script/core/rename.lua
+++ b/script/core/rename.lua
@@ -193,6 +193,9 @@ end
---@async
local function ofGlobal(source, newname, callback)
local key = guide.getKeyName(source)
+ if not key then
+ return
+ end
local global = vm.getGlobal('variable', key)
if not global then
return
diff --git a/script/core/signature.lua b/script/core/signature.lua
index f5de90d5..91b1156d 100644
--- a/script/core/signature.lua
+++ b/script/core/signature.lua
@@ -145,10 +145,10 @@ end
---@async
return function (uri, pos)
local state = files.getState(uri)
- if not state then
+ local text = files.getText(uri)
+ if not state or not text then
return nil
end
- local text = files.getText(uri)
local offset = guide.positionToOffset(state, pos)
pos = guide.offsetToPosition(state, lookback.skipSpace(text, offset))
local call = findNearCall(uri, state, pos)