From e0b86347ada4c7bc571422e598378772d579b4e4 Mon Sep 17 00:00:00 2001 From: ~hedy Date: Thu, 30 May 2024 07:52:51 +0800 Subject: [PATCH] feat: Focus outline if already open closes #71 --- CHANGELOG.md | 8 ++++++++ README.md | 3 +++ lua/outline/sidebar.lua | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c55d45e..8f740c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,14 @@ ### Others --> +## Main branch + +### Features + +- `OutlineOpen` (and `outline.open`) will now focus on the outline is already + open when run. + ([#71](https://github.com/hedyhli/outline.nvim/issues/71)) + ## v1.0.0 ### Breaking changes diff --git a/README.md b/README.md index 6f43c3e..13274ed 100644 --- a/README.md +++ b/README.md @@ -591,6 +591,9 @@ future. :OutlineOpen " opens with 'topleft vsplit' ``` + If the outline is already open, running this command without bang will focus + on the outline window. + - **:OutlineClose**: Close outline - **:OutlineFocus**: Toggle focus between outline and code/source window diff --git a/lua/outline/sidebar.lua b/lua/outline/sidebar.lua index 321b063..b35730c 100644 --- a/lua/outline/sidebar.lua +++ b/lua/outline/sidebar.lua @@ -600,6 +600,10 @@ function Sidebar:open(opts) if not cfg.o.outline_window.focus_on_open or not opts.focus_outline then vim.fn.win_gotoid(self.code.win) end + else + if cfg.o.outline_window.focus_on_open and opts.focus_outline then + self:focus() + end end end