From 5f912e6ad02f5259757f0c32a3c3a05ee3cb730c Mon Sep 17 00:00:00 2001 From: raven42 Date: Wed, 6 Jan 2021 06:23:55 -0600 Subject: [PATCH] Add `tagbar#IsOpen()` helper routine (#728) Closes #717 Add a `tagbar#IsOpen()` helper routine to check if the tagbar window is open or not. --- autoload/tagbar.vim | 12 ++++++++++++ doc/tagbar.txt | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 4aaf9a4..eac9f4a 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -3947,5 +3947,17 @@ function! tagbar#printfileinfo() abort echo 'Tagbar fileinfo printed to debug logfile' endfunction +" tagbar#IsOpen() {{{2 +function! tagbar#IsOpen() abort + let tagbarwinnr = bufwinnr('__Tagbar__') + if tagbarwinnr != -1 + " Window open + return 1 + else + " Window not open + return 0 + endif +endfunction + " Modeline {{{1 " vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 7e809ae..15c0460 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -351,11 +351,15 @@ FUNCTIONS *tagbar-functions* value. This also clears the internal flags to the file will be re-examined again. -tagbar#printfileinfo() +*tagbar#printfileinfo()* This function is used in conjunction with |TagbarDebug| and will print all the known tags into the tagbar debug logfile. This is useful for looking at the internal tag information that tagbar tracks. +*tagbar#IsOpen()* + This function will return 1 if the tagbar window is open, else it will + return 0. + ------------------------------------------------------------------------------ KEY MAPPINGS *tagbar-keys*