Skip to content

Commit

Permalink
fix(lsp): focus lost after :RustLsp codeAction second float opens (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Jan 25, 2024
1 parent bc8c4b8 commit 87fc16d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- LSP: Focus lost when secondary float opens on `:RustLsp codeAction` [[#169](https://github.com/mrcjkb/rustaceanvim/issues/169)].

## [3.17.3] - 2024-01-25

### Fixed
Expand Down
6 changes: 5 additions & 1 deletion lua/rustaceanvim/commands/code_action_group.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ end
---@param results { [number]: RACodeActionResult }
---@param ctx table
local function on_code_action_results(results, ctx)
local cur_win = vim.api.nvim_get_current_win()
M.state.ctx = ctx

---@type action_tuple[]
Expand Down Expand Up @@ -182,7 +183,10 @@ local function on_code_action_results(results, ctx)
vim.api.nvim_buf_attach(M.state.primary.bufnr, false, {
on_detach = function(_, _)
M.state.primary.clear()
vim.schedule(M.cleanup)
vim.schedule(function()
M.cleanup()
pcall(vim.api.nvim_set_current_win, cur_win)
end)
end,
})

Expand Down

0 comments on commit 87fc16d

Please sign in to comment.