Skip to content

Commit

Permalink
Merge pull request #49 from rasulomaroff/master
Browse files Browse the repository at this point in the history
fix: cursor disappearance #48
  • Loading branch information
otavioschwanck committed Apr 19, 2024
2 parents c6bbbb5 + 6ffff5f commit 37f32c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
15 changes: 7 additions & 8 deletions lua/arrow/buffer_ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ end
function M.spawn_action_windows(call_buffer, bookmarks, line_nr, col_nr, call_window, index)
local actions_buffer = vim.api.nvim_create_buf(false, true)

vim.api.nvim_set_hl(0, "ArrowCursor", { bg = "#ffffff", blend = 100 })
vim.opt.guicursor:append("a:ArrowCursor/ArrowCursor")

local lines_count = config.getState("per_buffer_config").lines

local width = math.ceil(vim.o.columns / 2)
Expand Down Expand Up @@ -405,20 +402,22 @@ function M.spawn_action_windows(call_buffer, bookmarks, line_nr, col_nr, call_wi
end, menuKeymapOpts)
end

vim.api.nvim_set_hl(0, "ArrowCursor", { nocombine = true, blend = 100 })
vim.opt.guicursor:append("a:ArrowCursor/ArrowCursor")

vim.api.nvim_create_autocmd("BufLeave", {
buffer = 0,
desc = "Disable Cursor",
once = true,
callback = function()
close_preview_windows()
if vim.api.nvim_buf_is_valid(actions_buffer) then
closeMenu(actions_buffer, call_buffer)
end

vim.cmd("highlight clear ArrowCursor")
vim.schedule(function()
if vim.api.nvim_buf_is_valid(actions_buffer) then
closeMenu(actions_buffer, call_buffer)
end

vim.opt.guicursor:remove("a:ArrowCursor/ArrowCursor")
vim.cmd("highlight clear ArrowCursor")
end)
end,
})
Expand Down
22 changes: 13 additions & 9 deletions lua/arrow/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,16 @@ function M.openMenu(bufnr)

vim.keymap.set("n", config.getState("leader_key"), closeMenu, menuKeymapOpts)

vim.keymap.set("n", config.getState("buffer_leader_key"), function()
closeMenu()
local buffer_leader_key = config.getState("buffer_leader_key")
if buffer_leader_key then
vim.keymap.set("n", buffer_leader_key, function()
closeMenu()

vim.schedule(function()
require("arrow.buffer_ui").openMenu(call_buffer)
end)
end, menuKeymapOpts)
vim.schedule(function()
require("arrow.buffer_ui").openMenu(call_buffer)
end)
end, menuKeymapOpts)
end

vim.keymap.set("n", mappings.quit, closeMenu, menuKeymapOpts)
vim.keymap.set("n", mappings.edit, function()
Expand Down Expand Up @@ -530,8 +533,7 @@ function M.openMenu(bufnr)
render_highlights(menuBuf)
end, menuKeymapOpts)

-- dumb color is needed for the highlight group to be applied
vim.api.nvim_set_hl(0, "ArrowCursor", { bg = "#ffffff", blend = 100 })
vim.api.nvim_set_hl(0, "ArrowCursor", { nocombine = true, blend = 100 })
vim.opt.guicursor:append("a:ArrowCursor/ArrowCursor")

vim.api.nvim_create_autocmd("BufLeave", {
Expand All @@ -541,8 +543,10 @@ function M.openMenu(bufnr)
callback = function()
current_index = 0

vim.opt.guicursor:remove("a:ArrowCursor/ArrowCursor")
vim.cmd("highlight clear ArrowCursor")
vim.schedule(function()
vim.opt.guicursor:remove("a:ArrowCursor/ArrowCursor")
end)
end,
})

Expand Down

0 comments on commit 37f32c9

Please sign in to comment.