Skip to content

Commit 1847e76

Browse files
authored
fix(texlab): buf_change_env not taking input #4116
Problem: `buf_change_env` uses `vim.ui.input` but the input prompt value is never used for `client:exec_cmd` (due to async). Solution: Call `client:exec_cmd` in `vim.ui.input`.
1 parent e688b48 commit 1847e76

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

lsp/texlab.lua

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,23 @@ local function buf_find_envs(client, bufnr)
111111
end
112112

113113
local function buf_change_env(client, bufnr)
114-
local new
115114
vim.ui.input({ prompt = 'New environment name: ' }, function(input)
116-
new = input
117-
end)
118-
if not new or new == '' then
119-
return vim.notify('No environment name provided', vim.log.levels.WARN)
120-
end
121-
local pos = vim.api.nvim_win_get_cursor(0)
122-
return client:exec_cmd({
123-
title = 'change_environment',
124-
command = 'texlab.changeEnvironment',
125-
arguments = {
126-
{
127-
textDocument = { uri = vim.uri_from_bufnr(bufnr) },
128-
position = { line = pos[1] - 1, character = pos[2] },
129-
newName = tostring(new),
115+
if not input or input == '' then
116+
return vim.notify('No environment name provided', vim.log.levels.WARN)
117+
end
118+
local pos = vim.api.nvim_win_get_cursor(0)
119+
return client:exec_cmd({
120+
title = 'change_environment',
121+
command = 'texlab.changeEnvironment',
122+
arguments = {
123+
{
124+
textDocument = { uri = vim.uri_from_bufnr(bufnr) },
125+
position = { line = pos[1] - 1, character = pos[2] },
126+
newName = tostring(input),
127+
},
130128
},
131-
},
132-
}, { bufnr = bufnr })
129+
}, { bufnr = bufnr })
130+
end)
133131
end
134132

135133
---@type vim.lsp.Config

0 commit comments

Comments
 (0)