Mercurial > vim
annotate runtime/plugin/rrhelper.vim @ 33872:2c5ae1ce5af2 v9.0.2146
patch 9.0.2146: text-property without type errors when joining
Commit: https://github.com/vim/vim/commit/0d0b3b19517c321b089d637919e88e49a07a3d85
Author: Christian Brabandt <cb@256bit.org>
Date: Sun Dec 3 17:56:43 2023 +0100
patch 9.0.2146: text-property without type errors when joining
Problem: text-property without type errors when joining
Solution: count all text-properties, with or without type
before joining lines
Error when joining lines with text properties without a proper type
When joining lines, we need to consider all text properties that are
attached to a line, even when those text properties are invalid and do
not have a type attached to them.
However, since patch v9.0.0993
(commit: 89469d157aea01513bde826b4519dd6b5fbceae4)
those text properties won't be counted when joining lines and therefore
this will cause the adjustment for text properties on joining to go
wrong (and may later cause SIGABRT with an invalid free pointer)
I am not sure, why the condition to not count text properties with a
valid type was added in patch v9.0.993, because no test fails if those
condition is removed. So let's just remove this condition and add a test
that verifies, that we are able to join lines, even when the text
properties attached to it do not have a valid type.
fixes: #13609
closes: #13614
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 10 Dec 2023 15:16:11 +0100 |
parents | f177a6431514 |
children |
rev | line source |
---|---|
7 | 1 " Vim plugin with helper function(s) for --remote-wait |
2 " Maintainer: Flemming Madsen <fma@cci.dk> | |
1623 | 3 " Last Change: 2008 May 29 |
7 | 4 |
5 " Has this already been loaded? | |
2325
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
6 if exists("loaded_rrhelper") || !has("clientserver") |
7 | 7 finish |
8 endif | |
9 let loaded_rrhelper = 1 | |
10 | |
11 " Setup answers for a --remote-wait client who will assume | |
12 " a SetupRemoteReplies() function in the command server | |
13 | |
2325
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
14 function SetupRemoteReplies() |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
15 let cnt = 0 |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
16 let max = argc() |
7 | 17 |
2325
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
18 let id = expand("<client>") |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
19 if id == 0 |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
20 return |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
21 endif |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
22 while cnt < max |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
23 " Handle same file from more clients and file being more than once |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
24 " on the command line by encoding this stuff in the group name |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
25 let uniqueGroup = "RemoteReply_".id."_".cnt |
7 | 26 |
2325
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
27 " Path separators are always forward slashes for the autocommand pattern. |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
28 " Escape special characters with a backslash. |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
29 let f = substitute(argv(cnt), '\\', '/', "g") |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
30 if exists('*fnameescape') |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
31 let f = fnameescape(f) |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
32 else |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
33 let f = escape(f, " \t\n*?[{`$\\%#'\"|!<") |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
34 endif |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
35 execute "augroup ".uniqueGroup |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
36 execute "autocmd ".uniqueGroup." BufUnload ". f ." call DoRemoteReply('".id."', '".cnt."', '".uniqueGroup."', '". f ."')" |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
37 let cnt = cnt + 1 |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
38 endwhile |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
39 augroup END |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
40 endfunc |
7 | 41 |
2325
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
42 function DoRemoteReply(id, cnt, group, file) |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
43 call server2client(a:id, a:cnt) |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
44 execute 'autocmd! '.a:group.' BufUnload '.a:file |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
45 execute 'augroup! '.a:group |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
46 endfunc |
7 | 47 |
48 " vim: set sw=2 sts=2 : |