Skip to content

Commit 17d141e

Browse files
committed
fix(eval): send the whole text to evaluate at once
The workaround of sending the messages directly to the powershell terminal is no longer required because since 2b62f06 the terminal is no longer blocked after each "evaluate" request
1 parent 0c775f1 commit 17d141e

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

lua/powershell/lsp.lua

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,11 @@ M.eval = function()
339339
local buf = api.nvim_get_current_buf()
340340
local client_id = util.clients_id[buf]
341341
if not client_id then
342-
vim.notify(
342+
return vim.notify(
343343
"There is no LSP client initialized by powershell.nvim attached to the current buffer.",
344344
vim.log.levels.WARN
345345
)
346-
return
347346
end
348-
local term_channel = assert(util.term_channel(buf))
349347

350348
local mode = api.nvim_get_mode().mode
351349
---@type string[]?
@@ -362,14 +360,10 @@ M.eval = function()
362360

363361
lines = api.nvim_buf_get_text(0, start_row, start_col, end_row, end_col, {})
364362
end
365-
vim
366-
.iter(lines)
367-
:map(function(line) return line .. "\r" end)
368-
:each(function(line) api.nvim_chan_send(term_channel, line) end)
369-
370-
-- TODO: wait for response on https://github.com/PowerShell/PowerShellEditorServices/issues/2164
371-
-- local client = assert(vim.lsp.get_client_by_id(client_id))
372-
-- client:request("evaluate", { expression = text }, util.noop, 0)
363+
assert(lines)
364+
365+
local client = assert(vim.lsp.get_client_by_id(client_id))
366+
client:request("evaluate", { expression = table.concat(lines, "\n") }, util.noop, 0)
373367
end
374368

375369
return M

0 commit comments

Comments
 (0)