patch 9.1.1758: Diff mode crashes when adding text property in autocommand Commit: https://github.com/vim/vim/commit/46e22fd2f73b03795a5922ba07621472713eddb3 Author: zeertzjq <zeert...@outlook.com> Date: Sun Sep 14 11:01:26 2025 -0400
patch 9.1.1758: Diff mode crashes when adding text property in autocommand Problem: Diff mode crashes when adding text property in autocommand (after 9.1.1557). Solution: Only restore ML_EMPTY memline flag, ignore the others (zeertzjq). fixes: #18288 closes: #18291 Signed-off-by: zeertzjq <zeert...@outlook.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/diff.c b/src/diff.c index 1a60ee7ae..25b9ae977 100644 --- a/src/diff.c +++ b/src/diff.c @@ -917,7 +917,8 @@ diff_write(buf_T *buf, diffin_T *din, linenr_T start, linenr_T end) cmdmod.cmod_flags = save_cmod_flags; free_string_option(buf->b_p_ff); buf->b_p_ff = save_ff; - buf->b_ml.ml_flags = save_ml_flags; + buf->b_ml.ml_flags = + (buf->b_ml.ml_flags & ~ML_EMPTY) | (save_ml_flags & ML_EMPTY); return r; } diff --git a/src/testdir/dumps/Test_diff_add_prop_in_autocmd_01.dump b/src/testdir/dumps/Test_diff_add_prop_in_autocmd_01.dump new file mode 100644 index 000000000..88aa421c1 --- /dev/null +++ b/src/testdir/dumps/Test_diff_add_prop_in_autocmd_01.dump @@ -0,0 +1,20 @@ +| +0#0000e05#a8a8a8255@1>f+0#0000000#ffff4012|o@1| @69 +| +0#0000e05#a8a8a8255@1|b+0#0000000#5fd7ff255|a|r| @69 +| +0#0000e05#a8a8a8255@1|b+0#0000000#5fd7ff255|a|z| @69 +|~+0#4040ff13#ffffff0| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|X+3#0000000&|d|i|f@1|s|p|l|i|t|_|f|i|l|e| @41|1|,|1| @11|A|l@1 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@72 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@72 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@72 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1 +|"+0&&|X|d|i|f@1|s|p|l|i|t|_|f|i|l|e|"| |3|L|,| |1|2|B| @49 diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim index 42f9463b3..340397a27 100644 --- a/src/testdir/test_diffmode.vim +++ b/src/testdir/test_diffmode.vim @@ -3541,4 +3541,29 @@ func Test_diffget_diffput_diffanchors() set diffanchors& endfunc +func Test_diff_add_prop_in_autocmd() + CheckScreendump + + let lines =<< trim END + func MyDiff() abort + let f1 = readfile(v:fname_in) + let f2 = readfile(v:fname_new) + let f0 = diff(f1, f2) + call writefile(split(f0, " "), v:fname_out) + endfunc + + call prop_type_add('myprop', #{highlight: 'Search', override: 1}) + autocmd OptionSet diff call prop_add(1, 1, #{type: 'myprop', length: 100}) + set diffexpr=MyDiff() + END + call writefile(lines, 'Xtest_diff_add_prop_in_autocmd', 'D') + call writefile(['foo', 'bar', 'baz'], 'Xdiffsplit_file', 'D') + + let buf = RunVimInTerminal('-S Xtest_diff_add_prop_in_autocmd', {}) + call term_sendkeys(buf, ":diffsplit Xdiffsplit_file\<CR>") + call VerifyScreenDump(buf, 'Test_diff_add_prop_in_autocmd_01', {}) + + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 51079ce76..e550f2f47 100644 --- a/src/version.c +++ b/src/version.c @@ -724,6 +724,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1758, /**/ 1757, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1uxoRV-006Eu1-RT%40256bit.org.