From 41e7b88a2b0baa90619af5ec8af462fcb442db65 Mon Sep 17 00:00:00 2001 From: ~hedy Date: Mon, 9 Sep 2024 15:29:59 +0800 Subject: [PATCH] fix: Error on goto_location when code window closed Mentioned by @gennaro-tedesco in #91 --- CHANGELOG.md | 3 ++- lua/outline/sidebar.lua | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ce40aa..15084ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lua/outline/sidebar.lua b/lua/outline/sidebar.lua index b35730c..0d79586 100644 --- a/lua/outline/sidebar.lua +++ b/lua/outline/sidebar.lua @@ -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