xeluxee / competitest.nvim

CompetiTest.nvim is a Neovim plugin for Competitive Programming: it can manage and check testcases, download problems and contests from online judges and much more
GNU Lesser General Public License v3.0
389 stars 16 forks source link

Error in runner_ui #2

Closed shadmansaleh closed 2 years ago

shadmansaleh commented 2 years ago

When I run :CompetiTestRun I get the following error.

E5108: Error executing lua ...ker/start/competitest.nvim/lua/competitest/runner_ui.lua:437: Expected Lua number
stack traceback:
        [C]: in function 'nvim_set_current_win'
        ...ker/start/competitest.nvim/lua/competitest/runner_ui.lua:437: in function 'delete_ui'
        ...ker/start/competitest.nvim/lua/competitest/runner_ui.lua:83: in function 'init_ui'
        ...packer/start/competitest.nvim/lua/competitest/runner.lua:305: in function 'show_ui'
        ...cker/start/competitest.nvim/lua/competitest/commands.lua:81: in function 'run_testcases'
        [string ":lua"]:1: in main chunk

I'm using nvim-0.7 . I think you're calling nvim_set_current_win with nil.

xeluxee commented 2 years ago

I'm not experiencing this issue since I'm using Neovim 0.6 I'll fix it as soon as possible

shadmansaleh commented 2 years ago

This patch does seem to remove the error but I'm not sure if 0 is appropriate value in this case

diff --git a/lua/competitest/runner_ui.lua b/lua/competitest/runner_ui.lua
index c57d45e..409b359 100644
--- a/lua/competitest/runner_ui.lua
+++ b/lua/competitest/runner_ui.lua
@@ -422,7 +422,7 @@ function M.hide_ui()
        end
    end
    M.options.ui_visible = false
-   api.nvim_set_current_win(M.options.restore_winid)
+   api.nvim_set_current_win(M.options.restore_winid or 0)
 end

 function M.delete_ui()
@@ -434,7 +434,7 @@ function M.delete_ui()
    end
    M.options.ui_visible = false
    M.options.viewer_visible = false
-   api.nvim_set_current_win(M.options.restore_winid)
+   api.nvim_set_current_win(M.options.restore_winid or 0)
 end

 return M
xeluxee commented 2 years ago

@shadmansaleh thanks for your patch 9b3bc04a498564b47d20bd233069b4f41c665663 should fix this issue, could you give it a try?

shadmansaleh commented 2 years ago

I've been using this patch since morning and it seems to be working so closing the issue .