Skip to content

Commit

Permalink
refactor: change exit shortcut to qa
Browse files Browse the repository at this point in the history
  • Loading branch information
kawre committed Mar 9, 2024
1 parent 4cfdafc commit 2d8a306
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 6 additions & 12 deletions lua/leetcode-ui/layout/console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ local log = require("leetcode.logger")
---@field testcase lc.ui.Console.TestcasePopup
---@field result lc.ui.Console.ResultPopup
---@field popups lc.ui.Console.Popup[]
---@field prev_winid integer
local ConsoleLayout = Layout:extend("LeetConsoleLayout")

function ConsoleLayout:unmount() --
Expand All @@ -25,19 +24,15 @@ function ConsoleLayout:unmount() --
self.popups = { self.testcase, self.result }
end

function ConsoleLayout:show()
self.prev_winid = vim.api.nvim_get_current_win()

ConsoleLayout.super.show(self)
end

function ConsoleLayout:hide()
ConsoleLayout.super.hide(self)

if self.prev_winid and vim.api.nvim_win_is_valid(self.prev_winid) then
vim.api.nvim_set_current_win(self.prev_winid)
self.prev_winid = nil
end
pcall(function()
local winid = vim.api.nvim_get_current_win()
if winid == self.question.description.winid then
vim.api.nvim_set_current_win(self.question.winid)
end
end)
end

function ConsoleLayout:mount()
Expand Down Expand Up @@ -97,7 +92,6 @@ function ConsoleLayout:init(parent)
self.testcase = Testcase(self)
self.result = Result(self)
self.popups = { self.testcase, self.result }
self.prev_winid = nil

ConsoleLayout.super.init(
self,
Expand Down
2 changes: 1 addition & 1 deletion lua/leetcode-ui/lines/button/menu/exit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local MenuExitButton = MenuButton:extend("LeetMenuExitButton")
function MenuExitButton:init()
MenuExitButton.super.init(self, "Exit", {
icon = "󰩈",
sc = "q",
sc = "qa",
on_press = leetcode.stop,
})
end
Expand Down

0 comments on commit 2d8a306

Please sign in to comment.