@@ -14,7 +14,6 @@ local log = require("leetcode.logger")
1414--- @field testcase lc.ui.Console.TestcasePopup
1515--- @field result lc.ui.Console.ResultPopup
1616--- @field popups lc.ui.Console.Popup[]
17- --- @field prev_winid integer
1817local ConsoleLayout = Layout :extend (" LeetConsoleLayout" )
1918
2019function ConsoleLayout :unmount () --
@@ -25,19 +24,15 @@ function ConsoleLayout:unmount() --
2524 self .popups = { self .testcase , self .result }
2625end
2726
28- function ConsoleLayout :show ()
29- self .prev_winid = vim .api .nvim_get_current_win ()
30-
31- ConsoleLayout .super .show (self )
32- end
33-
3427function ConsoleLayout :hide ()
3528 ConsoleLayout .super .hide (self )
3629
37- if self .prev_winid and vim .api .nvim_win_is_valid (self .prev_winid ) then
38- vim .api .nvim_set_current_win (self .prev_winid )
39- self .prev_winid = nil
40- end
30+ pcall (function ()
31+ local winid = vim .api .nvim_get_current_win ()
32+ if winid == self .question .description .winid then
33+ vim .api .nvim_set_current_win (self .question .winid )
34+ end
35+ end )
4136end
4237
4338function ConsoleLayout :mount ()
@@ -97,7 +92,6 @@ function ConsoleLayout:init(parent)
9792 self .testcase = Testcase (self )
9893 self .result = Result (self )
9994 self .popups = { self .testcase , self .result }
100- self .prev_winid = nil
10195
10296 ConsoleLayout .super .init (
10397 self ,
0 commit comments