summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/files.lua25
-rw-r--r--script/proto/proto.lua2
-rw-r--r--script/provider/diagnostic.lua4
-rw-r--r--script/provider/provider.lua11
4 files changed, 29 insertions, 13 deletions
diff --git a/script/files.lua b/script/files.lua
index 659a1aa0..d6c8f750 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -3,7 +3,6 @@ local config = require 'config'
local glob = require 'glob'
local furi = require 'file-uri'
local parser = require 'parser'
-local proto = require 'proto'
local lang = require 'language'
local await = require 'await'
local timer = require 'timer'
@@ -174,18 +173,18 @@ function m.setText(uri, text, isTrust, instance)
end
end
- if instance or TEST then
- m.onWatch('update', uri)
- else
- await.call(function ()
- await.close('update:' .. uri)
- await.setID('update:' .. uri)
- await.sleep(0.1)
- if m.exists(uri) then
- m.onWatch('update', uri)
- end
- end)
- end
+ --if instance or TEST then
+ m.onWatch('update', uri)
+ --else
+ -- await.call(function ()
+ -- await.close('update:' .. uri)
+ -- await.setID('update:' .. uri)
+ -- await.sleep(0.1)
+ -- if m.exists(uri) then
+ -- m.onWatch('update', uri)
+ -- end
+ -- end)
+ --end
end
function m.resetText(uri)
diff --git a/script/proto/proto.lua b/script/proto/proto.lua
index 7767ec0a..6010ef19 100644
--- a/script/proto/proto.lua
+++ b/script/proto/proto.lua
@@ -46,6 +46,8 @@ function m.responseErr(id, code, message)
log.error('Response id is nil!', util.dump(message))
return
end
+ assert(m.holdon[id])
+ m.holdon[id] = nil
local buf = jsonrpc.encode {
id = id,
error = {
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 382b73d9..492b3048 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -127,6 +127,7 @@ local function mergeSyntaxAndDiags(a, b)
end
function m.clear(uri)
+ await.close('diag:' .. uri)
if not m.cache[uri] then
return
end
@@ -212,6 +213,8 @@ function m.doDiagnostic(uri)
return
end
+ await.setID('diag:' .. uri)
+
local prog <close> = progress.create(lang.script.WINDOW_DIAGNOSING, 0.5)
prog:setMessage(ws.getRelativePath(uri))
@@ -261,6 +264,7 @@ function m.refresh(uri)
if not m._start then
return
end
+ await.close('diag:' .. uri)
await.call(function ()
await.delay()
if uri then
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 3f64494d..83e2b7da 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -855,3 +855,14 @@ config.watch(function (key, value)
end
end
end)
+
+files.watch(function (ev, uri)
+ if ev == 'update'
+ or ev == 'remove' then
+ for id, p in pairs(proto.holdon) do
+ if p.params.textDocument and p.params.textDocument.uri == uri then
+ proto.close(id, define.ErrorCodes.ContentModified)
+ end
+ end
+ end
+end)