p00f / cphelper.nvim

Neovim helper for competitive programming. Use https://sr.ht/~p00f/cphelper.nvim instead
MIT License
130 stars 9 forks source link

fix CphTest with number arguments #20

Closed kakig closed 2 years ago

kakig commented 2 years ago

This pull request fixes an issue when using CphTest with arguments.

Running CphTest 1 gives the following error:

E5108: Error executing lua Vim:E484: Can't open file inputinput1
stack traceback:
        [C]: in function 'readfile'
        ...ack/packer/start/cphelper.nvim/lua/cphelper/run_test.lua:15: in function 'run_test'
        ...acker/start/cphelper.nvim/lua/cphelper/process_tests.lua:30: in function 'iterate_cases'
        ...acker/start/cphelper.nvim/lua/cphelper/process_tests.lua:102: in function 'process_retests'
        ...acker/start/cphelper.nvim/lua/cphelper/process_tests.lua:94: in function 'process'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue

It seems like the case variable was already the complete filename, so by prepending "input", we ended up with inputinput1 as filename, which doesn't exist. I just removed the prepending part of the code.

p00f commented 2 years ago

This doesn't make sense though - the command CphTest passes its arguments as-it-is to process_tests.process, which passes them as-it-is to iterate_cases

p00f commented 2 years ago

If i print the case_numbers table in iterate_cases I get { "1" }

p00f commented 2 years ago

If I print case before this line https://github.com/p00f/cphelper.nvim/blob/4bc91f27a29dad0eaeda6c3470924f6e1174f4aa/lua/cphelper/process_tests.lua#L30 I get only 1

p00f commented 2 years ago

Ah understood

p00f commented 2 years ago

Thanks!