changeset 28837:64c3323117b4 v8.2.4942

patch 8.2.4942: error when setting 'filetype' in help file again Commit: https://github.com/vim/vim/commit/de216732d45caa87e6f08f4319aa71e805a89a0e Author: Bram Moolenaar <Bram@vim.org> Date: Thu May 12 17:24:49 2022 +0100 patch 8.2.4942: error when setting 'filetype' in help file again Problem: Error when setting 'filetype' in help file again. Solution: Deal with text property type already existing. (closes https://github.com/vim/vim/issues/10409)
author Bram Moolenaar <Bram@vim.org>
date Thu, 12 May 2022 18:30:05 +0200
parents 60e7b3a726e7
children 56bcafbfd84a
files runtime/import/dist/vimhelp.vim src/version.c
diffstat 2 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/import/dist/vimhelp.vim
+++ b/runtime/import/dist/vimhelp.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4942,
+/**/
     4941,
 /**/
     4940,