aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2021-07-14 12:06:18 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2021-07-14 12:06:18 +0200
commitc1ad992c89a4f4cb79c1e2bfec25b7f5dc00c321 (patch)
tree706d49e89b82b85bb03d1f0c48389b860d9e2081 /init.lua
parent8576ccbb3548102c112900cc8430147017b38b91 (diff)
downloadvis-lspc-c1ad992c89a4f4cb79c1e2bfec25b7f5dc00c321.tar.gz
vis-lspc-c1ad992c89a4f4cb79c1e2bfec25b7f5dc00c321.zip
apply WorkspaceEdit changes in all open windows
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua21
1 files changed, 13 insertions, 8 deletions
diff --git a/init.lua b/init.lua
index 947133e..1ad56e9 100644
--- a/init.lua
+++ b/init.lua
@@ -428,9 +428,7 @@ local function lspc_confirm(prompt)
end
-- apply a WorkspaceEdit received from the language server
-local function vis_apply_workspaceEdit(win, file, workspaceEdit)
- assert(win.file == file)
-
+local function vis_apply_workspaceEdit(_, _, workspaceEdit)
local file_edits = workspaceEdit.changes
assert(file_edits)
@@ -457,16 +455,23 @@ local function vis_apply_workspaceEdit(win, file, workspaceEdit)
return
end
- -- apply changes
+ -- apply changes to open files
for uri, edits in pairs(file_edits) do
local path = uri_to_path(uri)
- if path == file.path then
- for _, edit in ipairs(edits) do
- vis_apply_textEdit(win, file, edit)
+ -- local open = false
+ -- search all open windows for this uri
+ for win in vis:windows() do
+ if win.file and win.file.path == path then
+ -- open = true
+ for _, edit in ipairs(edits) do
+ vis_apply_textEdit(win, win.file, edit)
+ end
end
end
- -- TODO: apply changes in different files
+ -- TODO: apply changes to not open files
+ -- if not open then
+ -- end
end
end