]> granicus.if.org Git - vim/commitdiff
patch 8.2.4942: error when setting 'filetype' in help file again v8.2.4942
authorBram Moolenaar <Bram@vim.org>
Thu, 12 May 2022 16:24:49 +0000 (17:24 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 12 May 2022 16:24:49 +0000 (17:24 +0100)
Problem:    Error when setting 'filetype' in help file again.
Solution:   Deal with text property type already existing. (closes #10409)

runtime/import/dist/vimhelp.vim
src/version.c

index 1f587251b904a6cdbb33a3945f65a49c521f5c7c..00cc79cfdbe53bbc648d3d3bb89daee93cf32f9d 100644 (file)
@@ -9,11 +9,17 @@ export def HighlightGroups()
   while getline(lnum) !~ '===' && lnum < line('$')
     var word: string = getline(lnum)->matchstr('^\w\+\ze\t')
     if word->hlexists()
-      prop_type_add('help-hl-' .. word, {
-       bufnr: buf,
-       highlight: word,
-       combine: false,
-       })
+      var name = 'help-hl-' .. word
+      if prop_type_list({bufnr: buf})->match(name) == -1
+       prop_type_add('help-hl-' .. word, {
+         bufnr: buf,
+         highlight: word,
+         combine: false,
+         })
+      else
+       # was called before, delete existing properties
+       prop_remove({type: name, bufnr: buf})
+      endif
       prop_add(lnum, 1, {length: word->strlen(), type: 'help-hl-' .. word})
     endif
     ++lnum
index f34a3226e980a323f2c5d9c1ef8b4d2949dedd04..480acfda11c7d0cfff37b634036f3029a2bdf254 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4942,
 /**/
     4941,
 /**/