Mercurial > vim
diff src/textprop.c @ 16770:09c81f17f83c v8.1.1387
patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
commit https://github.com/vim/vim/commit/d79eef2eb1f24b53206c4e55b80a4634f548c429
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 24 20:41:55 2019 +0200
patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Problem: Calling prop_add() in an empty buffer doesn't work. (Dominique
Pelle)
Solution: Open the memline before adding a text property. (closes #4412)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 24 May 2019 20:45:05 +0200 |
parents | 695d9ef00b03 |
children | 18093a6accb5 |
line wrap: on
line diff
--- a/src/textprop.c +++ b/src/textprop.c @@ -12,6 +12,7 @@ * * TODO: * - Adjust text property column and length when text is inserted/deleted. + * -> :substitute with multiple matches, issue #4427 * -> a :substitute with a multi-line match * -> search for changed_bytes() from misc1.c * -> search for mark_col_adjust() @@ -238,6 +239,9 @@ f_prop_add(typval_T *argvars, typval_T * return; } + if (buf->b_ml.ml_mfp == NULL) + ml_open(buf); + for (lnum = start_lnum; lnum <= end_lnum; ++lnum) { colnr_T col; // start column @@ -327,7 +331,7 @@ get_text_props(buf_T *buf, linenr_T lnum // Be quick when no text property types have been defined or the buffer, // unless we are adding one. - if (!buf->b_has_textprop && !will_change) + if ((!buf->b_has_textprop && !will_change) || buf->b_ml.ml_mfp == NULL) return 0; // Fetch the line to get the ml_line_len field updated.