Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reloading an modifiable octo buffer may cause a runtime error (#812
) Fixes: #811 ``` Error executing vim.schedule lua callback: ...hare/nvim/site/pack/deps/opt/octo.nvim/lua/octo/init.lua:111: Error executing lua: . ..hare/nvim/site/pack/deps/opt/octo.nvim/lua/octo/init.lua:119: Cursor position outside buffer stack traceback: [C]: in function 'nvim_win_set_cursor' ...hare/nvim/site/pack/deps/opt/octo.nvim/lua/octo/init.lua:119: in function <...hare/nvim/site/pack/deps/opt/octo.nvim/lu a/octo/init.lua:111> [C]: in function 'nvim_buf_call' ...hare/nvim/site/pack/deps/opt/octo.nvim/lua/octo/init.lua:111: in function 'cb' ...hare/nvim/site/pack/deps/opt/octo.nvim/lua/octo/init.lua:150: in function 'cb' ...e/nvim/site/pack/deps/opt/octo.nvim/lua/octo/gh/init.lua:163: in function '' vim/_editor.lua: in function <vim/_editor.lua:0> stack traceback: [C]: in function 'nvim_buf_call' ...hare/nvim/site/pack/deps/opt/octo.nvim/lua/octo/init.lua:111: in function 'cb' ...hare/nvim/site/pack/deps/opt/octo.nvim/lua/octo/init.lua:150: in function 'cb' ...e/nvim/site/pack/deps/opt/octo.nvim/lua/octo/gh/init.lua:163: in function '' vim/_editor.lua: in function <vim/_editor.lua:0> ``` The above runtime error can occur when an Octo buffer is modified and then a reload command is used. The issue occurs when capturing the initial cursor position before reload of the Octo buffer. The initial cursor position may be in an invalid position in the current Octo buffer by the time the reloaded buffer is loaded int. Simply get the lines of the newly loaded buffer and only cursor reset at the minimum valid row position. The real-world reason to fix this is to avoid a subtly but possibly annoying runtime error when the user performs "Octo comment add" in an issue buffer and then reloads the buffer without submitting the comment. Signed-off-by: ldelossa <[email protected]>
- Loading branch information