diff options
-rw-r--r-- | changelog.md | 3 | ||||
-rw-r--r-- | script/files.lua | 2 | ||||
-rw-r--r-- | script/provider/diagnostic.lua | 5 | ||||
-rw-r--r-- | script/provider/provider.lua | 5 |
4 files changed, 8 insertions, 7 deletions
diff --git a/changelog.md b/changelog.md index e12528f1..ee9f2fcf 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # changelog +## 2.5.2 +* `FIX` [#837](https://github.com/sumneko/lua-language-server/issues/837) + ## 2.5.1 `2021-11-29` * `FIX` incorrect syntax error diff --git a/script/files.lua b/script/files.lua index 9ae58dfe..074a262e 100644 --- a/script/files.lua +++ b/script/files.lua @@ -177,6 +177,7 @@ function m.setText(uri, text, isTrust, version) local encoding = config.get 'Lua.runtime.fileEncoding' text = encoder.decode(encoding, text) end + file.version = version if file.originText == text then return end @@ -189,7 +190,6 @@ function m.setText(uri, text, isTrust, version) m.astMap[uri] = nil file.cache = {} file.cacheActiveTime = math.huge - file.version = version m.globalVersion = m.globalVersion + 1 await.close('files.version') m.onWatch('version') diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index ca4bcdb8..e90d8afb 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -223,8 +223,6 @@ function m.doDiagnostic(uri) local version = files.getVersion(uri) - await.setID('diag:' .. uri) - local prog <close> = progress.create(lang.script.WINDOW_DIAGNOSING, 0.5) prog:setMessage(ws.getRelativePath(uri)) @@ -277,8 +275,9 @@ function m.refresh(uri) end await.close('diag:' .. uri) await.call(function () ---@async - await.delay() if uri then + await.setID('diag:' .. uri) + await.sleep(0.1) m.clearCache(uri) xpcall(m.doDiagnostic, log.error, uri) end diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 7f025f78..8e64f5d3 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -210,8 +210,7 @@ m.register 'textDocument/didOpen' { local doc = params.textDocument local uri = files.getRealUri(doc.uri) local text = doc.text - log.debug('didOpen', uri) - files.setText(uri, text, true) + files.setText(uri, text, true, doc.version) files.open(uri) end } @@ -239,7 +238,7 @@ m.register 'textDocument/didChange' { local text = files.getOriginText(uri) or '' local rows = files.getCachedRows(uri) text, rows = tm(text, rows, changes) - files.setText(uri, text, true) + files.setText(uri, text, true, doc.version) files.setCachedRows(uri, rows) end } |