Skip to content

Commit

Permalink
fix: Error on goto_location when code window closed
Browse files Browse the repository at this point in the history
Mentioned by @gennaro-tedesco in #91
  • Loading branch information
hedyhli committed Sep 9, 2024
1 parent 3725c65 commit 41e7b88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions lua/outline/sidebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41e7b88

Please sign in to comment.