Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Go back to original window after code action execution #367

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lua/rust-tools/code_action_group.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ function M.cleanup()
M.state.secondary.clear()
end

if M.state.ctx.win then
vim.api.nvim_set_current_win(M.state.ctx.win)
end

M.state.actions = {}
M.state.active_group_index = nil
M.state.ctx = {}
Expand Down Expand Up @@ -367,6 +371,7 @@ function M.code_action_group()
context.diagnostics = vim.lsp.diagnostic.get_line_diagnostics()
local params = vim.lsp.util.make_range_params()
params.context = context
local win = vim.api.nvim_get_current_win()

vim.lsp.buf_request_all(
0,
Expand All @@ -375,7 +380,12 @@ function M.code_action_group()
function(results)
on_code_action_results(
results,
{ bufnr = 0, method = "textDocument/codeAction", params = params }
{
bufnr = 0,
method = "textDocument/codeAction",
params = params,
win = win
}
)
end
)
Expand Down