fix: Error on goto_location when code window closed

Mentioned by @gennaro-tedesco in #91
This commit is contained in:
~hedy
2024-09-09 15:29:59 +08:00
parent 3725c652f2
commit 41e7b88a2b
2 changed files with 7 additions and 1 deletions

View File

@@ -32,8 +32,9 @@
- Allow the preview window's width and height adapt to nvim window's resize.
([#85](https://github.com/hedyhli/outline.nvim/pull/85))
- Keybinding to close the outline will exit neovim if it is the last window
remaining; previously this throwed an error.
remaining; previously this threw an error.
([#91](https://github.com/hedyhli/outline.nvim/pull/91))
- Prevent an error on attempt to `goto_location` when code window is closed.
## v1.0.0

View File

@@ -386,6 +386,11 @@ function Sidebar:__goto_location(change_focus)
return
end
if not vim.api.nvim_win_is_valid(self.code.win) then
vim.notify("outline.nvim: Code window closed", vim.log.levels.WARN)
return
end
vim.api.nvim_win_set_cursor(self.code.win, { node.line + 1, node.character })
if cfg.o.outline_window.center_on_jump then