Mercurial > vim
annotate runtime/import/dist/vimhelp.vim @ 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 | db38dab0e525 |
children | c58baa6d6dda |
rev | line source |
---|---|
28733
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 vim9script |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 # Extra functionality for displaying Vim help . |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 # Called when editing the doc/syntax.txt file |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 export def HighlightGroups() |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 var buf: number = bufnr('%') |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 var lnum: number = search('\*highlight-groups\*', 'cn') |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 while getline(lnum) !~ '===' && lnum < line('$') |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 var word: string = getline(lnum)->matchstr('^\w\+\ze\t') |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 if word->hlexists() |
28837
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
12 var name = 'help-hl-' .. word |
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
13 if prop_type_list({bufnr: buf})->match(name) == -1 |
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
14 prop_type_add('help-hl-' .. word, { |
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
15 bufnr: buf, |
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
16 highlight: word, |
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
17 combine: false, |
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
18 }) |
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
19 else |
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
20 # was called before, delete existing properties |
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
21 prop_remove({type: name, bufnr: buf}) |
64c3323117b4
patch 8.2.4942: error when setting 'filetype' in help file again
Bram Moolenaar <Bram@vim.org>
parents:
28733
diff
changeset
|
22 endif |
28733
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 prop_add(lnum, 1, {length: word->strlen(), type: 'help-hl-' .. word}) |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 endif |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 ++lnum |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 endwhile |
db38dab0e525
patch 8.2.4891: Vim help presentation could be better
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 enddef |