From 24fcd43c0f6087b23a1ae6b0e3959f4f2742a8a6 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Tue, 28 Mar 2023 22:51:50 -0700 Subject: [PATCH 1/3] fix: WikiTagRename failure after so many tags It appears as though we may be killing a reference to self.collection[o:old_tag] prematurely, thus causing subsequent tags to be renamed. --- autoload/wiki/tags.vim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/autoload/wiki/tags.vim b/autoload/wiki/tags.vim index b93ec87..36d8fc0 100644 --- a/autoload/wiki/tags.vim +++ b/autoload/wiki/tags.vim @@ -407,8 +407,6 @@ function! s:tags.rename(old_tag, new_tag, ...) abort dict " {{{1 call wiki#log#info('Renaming tag "' . a:old_tag . '" to "' . a:new_tag . '".') - let l:tagpages = self.collection[a:old_tag] - let l:bufnr = bufnr('') " Get list of open wiki buffers let l:bufs = @@ -425,16 +423,21 @@ function! s:tags.rename(old_tag, new_tag, ...) abort dict " {{{1 endfor let l:num_files = 0 + let l:tagpages = deepcopy(self.collection[a:old_tag]) " We already know where the tag is in the file, thanks to the cache for [l:file, l:lnum] in l:tagpages if s:update_tag_in_wiki(l:file, l:lnum, a:old_tag, a:new_tag) call self.add(a:new_tag, l:file, l:lnum) - call remove(self.collection, a:old_tag) + call remove(self.collection[a:old_tag], 0) let l:num_files += 1 endif endfor + if empty(self.collection->get(a:old_tag)) + call remove(self.collection, a:old_tag) + endif + " Refresh other wiki buffers for l:bufname in l:bufs execute 'buffer' fnameescape(l:bufname) From 1d81add270a64358a84afbfa7cc10bb03e30c5d6 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Wed, 29 Mar 2023 19:32:24 -0700 Subject: [PATCH 2/3] fix: method syntax breaks current compatibility --- autoload/wiki/tags.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/wiki/tags.vim b/autoload/wiki/tags.vim index 36d8fc0..3457a71 100644 --- a/autoload/wiki/tags.vim +++ b/autoload/wiki/tags.vim @@ -434,7 +434,7 @@ function! s:tags.rename(old_tag, new_tag, ...) abort dict " {{{1 endif endfor - if empty(self.collection->get(a:old_tag)) + if empty(get(self.collection, a:old_tag)) call remove(self.collection, a:old_tag) endif From 4b71bd24a85208b5954d318a3bac4591dc9c7a43 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Thu, 30 Mar 2023 08:19:13 -0700 Subject: [PATCH 3/3] fix: simplify wiki tag rename loop --- autoload/wiki/tags.vim | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/autoload/wiki/tags.vim b/autoload/wiki/tags.vim index 3457a71..99d214d 100644 --- a/autoload/wiki/tags.vim +++ b/autoload/wiki/tags.vim @@ -423,21 +423,16 @@ function! s:tags.rename(old_tag, new_tag, ...) abort dict " {{{1 endfor let l:num_files = 0 - let l:tagpages = deepcopy(self.collection[a:old_tag]) + let l:tagpages = remove(self.collection, a:old_tag) " We already know where the tag is in the file, thanks to the cache for [l:file, l:lnum] in l:tagpages if s:update_tag_in_wiki(l:file, l:lnum, a:old_tag, a:new_tag) call self.add(a:new_tag, l:file, l:lnum) - call remove(self.collection[a:old_tag], 0) let l:num_files += 1 endif endfor - if empty(get(self.collection, a:old_tag)) - call remove(self.collection, a:old_tag) - endif - " Refresh other wiki buffers for l:bufname in l:bufs execute 'buffer' fnameescape(l:bufname)