From 5cb566b359fd430f7e759dbee3d79baaaacc1a23 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 29 Mar 2024 14:30:05 +0800 Subject: [PATCH] perf(bookmarks): skip empty bufname & buftype --- bundle/bookmarks.vim/autoload/bookmarks.vim | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bundle/bookmarks.vim/autoload/bookmarks.vim b/bundle/bookmarks.vim/autoload/bookmarks.vim index 77790ee45..398102dad 100644 --- a/bundle/bookmarks.vim/autoload/bookmarks.vim +++ b/bundle/bookmarks.vim/autoload/bookmarks.vim @@ -9,7 +9,20 @@ let s:NT = SpaceVim#api#import('notify') let s:bookmarks = bookmarks#cache#read() +function! s:skip_current_buf() abort + if empty(bufname()) + call s:NT.notify('skip empty bufname.') + return v:true + elseif !empty(&buftype) + call s:NT.notify('skip buftype: ' . &buftype) + return v:true + endif +endfunction + function! bookmarks#toggle() abort + if s:skip_current_buf() + return + endif let file = s:FILE.unify_path(expand('%'), ':p') let lnum = line('.') if has_key(s:bookmarks, file) && has_key(s:bookmarks[file], lnum) @@ -27,7 +40,9 @@ function! s:has_annotation(file, lnum) abort endfunction function! bookmarks#annotate() abort - + if s:skip_current_buf() + return + endif let file = s:FILE.unify_path(expand('%'), ':p') let lnum = line('.') if s:has_annotation(file, lnum)