diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-12-13 22:20:09 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-12-13 22:20:09 +0100 |
commit | 98aefe7c3250bb5d4153b994f878594d1745424e (patch) | |
tree | 262ae31c2dbf4ac0353f5564a2419a79267fa3ae /src/misc1.c | |
parent | 5c5697f29829fc3b21fc5452fe8f239f6a4cb8e1 (diff) | |
download | vim-git-98aefe7c3250bb5d4153b994f878594d1745424e.tar.gz |
patch 8.1.0579: cannot attach properties to textv8.1.0579
Problem: Cannot attach properties to text.
Solution: First part of adding text properties.
Diffstat (limited to 'src/misc1.c')
-rw-r--r-- | src/misc1.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/misc1.c b/src/misc1.c index f1f007478..40d6f93c5 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -2631,9 +2631,10 @@ del_bytes( { char_u *oldp, *newp; colnr_T oldlen; + colnr_T newlen; linenr_T lnum = curwin->w_cursor.lnum; colnr_T col = curwin->w_cursor.col; - int was_alloced; + int alloc_newp; long movelen; int fixpos = fixpos_arg; @@ -2710,6 +2711,7 @@ del_bytes( count = oldlen - col; movelen = 1; } + newlen = oldlen - count; /* * If the old line has been allocated the deletion can be done in the @@ -2720,24 +2722,34 @@ del_bytes( */ #ifdef FEAT_NETBEANS_INTG if (netbeans_active()) - was_alloced = FALSE; + alloc_newp = TRUE; else #endif - was_alloced = ml_line_alloced(); /* check if oldp was allocated */ - if (was_alloced) - newp = oldp; /* use same allocated memory */ + alloc_newp = !ml_line_alloced(); // check if oldp was allocated + if (!alloc_newp) + newp = oldp; // use same allocated memory else - { /* need to allocate a new line */ - newp = alloc((unsigned)(oldlen + 1 - count)); + { // need to allocate a new line + newp = alloc((unsigned)(newlen + 1)); if (newp == NULL) return FAIL; mch_memmove(newp, oldp, (size_t)col); } mch_memmove(newp + col, oldp + col + count, (size_t)movelen); - if (!was_alloced) + if (alloc_newp) ml_replace(lnum, newp, FALSE); +#ifdef FEAT_TEXT_PROP + else + { + // Also move any following text properties. + if (oldlen + 1 < curbuf->b_ml.ml_line_len) + mch_memmove(newp + newlen + 1, oldp + oldlen + 1, + (size_t)curbuf->b_ml.ml_line_len - oldlen - 1); + curbuf->b_ml.ml_line_len -= count; + } +#endif - /* mark the buffer as changed and prepare for displaying */ + // mark the buffer as changed and prepare for displaying changed_bytes(lnum, curwin->w_cursor.col); return OK; |