mirror of
https://github.com/vim/vim.git
synced 2025-11-16 23:24:03 -05:00
patch 8.1.0579: cannot attach properties to text
Problem: Cannot attach properties to text. Solution: First part of adding text properties.
This commit is contained in:
30
src/misc1.c
30
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;
|
||||
|
||||
Reference in New Issue
Block a user