mirror of
https://github.com/neovim/neovim.git
synced 2025-11-24 19:20:39 +00:00
extmark: separate extmark_splice_cols for column-only change
as the byte logic will be the same for all of these
This commit is contained in:
@@ -366,7 +366,7 @@ void changed_bytes(linenr_T lnum, colnr_T col)
|
|||||||
static void inserted_bytes(linenr_T lnum, colnr_T col, int old, int new)
|
static void inserted_bytes(linenr_T lnum, colnr_T col, int old, int new)
|
||||||
{
|
{
|
||||||
if (curbuf_splice_pending == 0) {
|
if (curbuf_splice_pending == 0) {
|
||||||
extmark_splice(curbuf, (int)lnum-1, col, 0, old, 0, new, kExtmarkUndo);
|
extmark_splice_cols(curbuf, (int)lnum-1, col, old, new, kExtmarkUndo);
|
||||||
}
|
}
|
||||||
|
|
||||||
changed_bytes(lnum, col);
|
changed_bytes(lnum, col);
|
||||||
|
|||||||
@@ -1919,10 +1919,10 @@ change_indent (
|
|||||||
// TODO(bfredl): test for crazy edge cases, like we stand on a TAB or
|
// TODO(bfredl): test for crazy edge cases, like we stand on a TAB or
|
||||||
// something? does this even do the right text change then?
|
// something? does this even do the right text change then?
|
||||||
int delta = orig_col - new_col;
|
int delta = orig_col - new_col;
|
||||||
extmark_splice(curbuf, curwin->w_cursor.lnum-1, new_col,
|
extmark_splice_cols(curbuf, curwin->w_cursor.lnum-1, new_col,
|
||||||
0, delta < 0 ? -delta : 0,
|
delta < 0 ? -delta : 0,
|
||||||
0, delta > 0 ? delta : 0,
|
delta > 0 ? delta : 0,
|
||||||
kExtmarkUndo);
|
kExtmarkUndo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -552,6 +552,7 @@ void extmark_adjust(buf_T *buf,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void extmark_splice(buf_T *buf,
|
void extmark_splice(buf_T *buf,
|
||||||
int start_row, colnr_T start_col,
|
int start_row, colnr_T start_col,
|
||||||
int oldextent_row, colnr_T oldextent_col,
|
int oldextent_row, colnr_T oldextent_col,
|
||||||
@@ -631,12 +632,10 @@ void extmark_splice(buf_T *buf,
|
|||||||
|
|
||||||
void extmark_splice_cols(buf_T *buf,
|
void extmark_splice_cols(buf_T *buf,
|
||||||
int start_row, colnr_T start_col,
|
int start_row, colnr_T start_col,
|
||||||
colnr_T old_col, colnr_T new_col,
|
colnr_T oldextent, colnr_T newextent,
|
||||||
ExtmarkOp undo)
|
ExtmarkOp undo)
|
||||||
{
|
{
|
||||||
extmark_splice(buf, start_row, start_col,
|
extmark_splice(buf, start_row, start_col, 0, oldextent, 0, newextent, undo);
|
||||||
0, old_col,
|
|
||||||
0, new_col, undo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void extmark_move_region(buf_T *buf,
|
void extmark_move_region(buf_T *buf,
|
||||||
|
|||||||
@@ -1744,8 +1744,7 @@ static void foldDelMarker(
|
|||||||
STRCPY(newline + (p - line), p + len);
|
STRCPY(newline + (p - line), p + len);
|
||||||
ml_replace_buf(buf, lnum, newline, false);
|
ml_replace_buf(buf, lnum, newline, false);
|
||||||
extmark_splice_cols(buf, (int)lnum-1, (int)(p - line),
|
extmark_splice_cols(buf, (int)lnum-1, (int)(p - line),
|
||||||
(int)len,
|
(int)len, 0, kExtmarkUndo);
|
||||||
0, kExtmarkUndo);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -496,9 +496,9 @@ static void shift_block(oparg_T *oap, int amount)
|
|||||||
// replace the line
|
// replace the line
|
||||||
ml_replace(curwin->w_cursor.lnum, newp, false);
|
ml_replace(curwin->w_cursor.lnum, newp, false);
|
||||||
changed_bytes(curwin->w_cursor.lnum, (colnr_T)bd.textcol);
|
changed_bytes(curwin->w_cursor.lnum, (colnr_T)bd.textcol);
|
||||||
extmark_splice(curbuf, (int)curwin->w_cursor.lnum-1, startcol,
|
extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum-1, startcol,
|
||||||
0, oldlen, 0, newlen,
|
oldlen, newlen,
|
||||||
kExtmarkUndo);
|
kExtmarkUndo);
|
||||||
State = oldstate;
|
State = oldstate;
|
||||||
curwin->w_cursor.col = oldcol;
|
curwin->w_cursor.col = oldcol;
|
||||||
p_ri = old_p_ri;
|
p_ri = old_p_ri;
|
||||||
@@ -595,9 +595,8 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def
|
|||||||
STRMOVE(newp + offset, oldp);
|
STRMOVE(newp + offset, oldp);
|
||||||
|
|
||||||
ml_replace(lnum, newp, false);
|
ml_replace(lnum, newp, false);
|
||||||
extmark_splice(curbuf, (int)lnum-1, startcol,
|
extmark_splice_cols(curbuf, (int)lnum-1, startcol,
|
||||||
0, skipped,
|
skipped, offset-startcol, kExtmarkUndo);
|
||||||
0, offset-startcol, kExtmarkUndo);
|
|
||||||
|
|
||||||
if (lnum == oap->end.lnum) {
|
if (lnum == oap->end.lnum) {
|
||||||
/* Set "']" mark to the end of the block instead of the end of
|
/* Set "']" mark to the end of the block instead of the end of
|
||||||
@@ -1534,10 +1533,9 @@ int op_delete(oparg_T *oap)
|
|||||||
// replace the line
|
// replace the line
|
||||||
ml_replace(lnum, newp, false);
|
ml_replace(lnum, newp, false);
|
||||||
|
|
||||||
extmark_splice(curbuf, (int)lnum-1, bd.textcol,
|
extmark_splice_cols(curbuf, (int)lnum-1, bd.textcol,
|
||||||
0, bd.textlen,
|
bd.textlen, bd.startspaces+bd.endspaces,
|
||||||
0, bd.startspaces+bd.endspaces,
|
kExtmarkUndo);
|
||||||
kExtmarkUndo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_cursor_col();
|
check_cursor_col();
|
||||||
@@ -1711,7 +1709,7 @@ static inline void pbyte(pos_T lp, int c)
|
|||||||
assert(c <= UCHAR_MAX);
|
assert(c <= UCHAR_MAX);
|
||||||
*(ml_get_buf(curbuf, lp.lnum, true) + lp.col) = (char_u)c;
|
*(ml_get_buf(curbuf, lp.lnum, true) + lp.col) = (char_u)c;
|
||||||
if (!curbuf_splice_pending) {
|
if (!curbuf_splice_pending) {
|
||||||
extmark_splice(curbuf, (int)lp.lnum-1, lp.col, 0, 1, 0, 1, kExtmarkUndo);
|
extmark_splice_cols(curbuf, (int)lp.lnum-1, lp.col, 1, 1, kExtmarkUndo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2399,9 +2397,8 @@ int op_change(oparg_T *oap)
|
|||||||
oldp += bd.textcol;
|
oldp += bd.textcol;
|
||||||
STRMOVE(newp + offset, oldp);
|
STRMOVE(newp + offset, oldp);
|
||||||
ml_replace(linenr, newp, false);
|
ml_replace(linenr, newp, false);
|
||||||
extmark_splice(curbuf, (int)linenr-1, bd.textcol,
|
extmark_splice_cols(curbuf, (int)linenr-1, bd.textcol,
|
||||||
0, 0,
|
0, vpos.coladd+(int)ins_len, kExtmarkUndo);
|
||||||
0, vpos.coladd+(int)ins_len, kExtmarkUndo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
check_cursor();
|
check_cursor();
|
||||||
@@ -3182,10 +3179,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
assert(columns >= 0);
|
assert(columns >= 0);
|
||||||
memmove(ptr, oldp + bd.textcol + delcount, (size_t)columns);
|
memmove(ptr, oldp + bd.textcol + delcount, (size_t)columns);
|
||||||
ml_replace(curwin->w_cursor.lnum, newp, false);
|
ml_replace(curwin->w_cursor.lnum, newp, false);
|
||||||
extmark_splice(curbuf, (int)curwin->w_cursor.lnum-1, bd.textcol,
|
extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum-1, bd.textcol,
|
||||||
0, delcount,
|
delcount, (int)totlen, kExtmarkUndo);
|
||||||
0, (int)totlen,
|
|
||||||
kExtmarkUndo);
|
|
||||||
|
|
||||||
++curwin->w_cursor.lnum;
|
++curwin->w_cursor.lnum;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@@ -3309,9 +3304,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))
|
if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))
|
||||||
++curwin->w_cursor.col;
|
++curwin->w_cursor.col;
|
||||||
changed_bytes(lnum, col);
|
changed_bytes(lnum, col);
|
||||||
extmark_splice(curbuf, (int)lnum-1, col,
|
extmark_splice_cols(curbuf, (int)lnum-1, col,
|
||||||
0, 0,
|
0, (int)totlen, kExtmarkUndo);
|
||||||
0, (int)totlen, kExtmarkUndo);
|
|
||||||
} else {
|
} else {
|
||||||
// Insert at least one line. When y_type is kMTCharWise, break the first
|
// Insert at least one line. When y_type is kMTCharWise, break the first
|
||||||
// line in two.
|
// line in two.
|
||||||
|
|||||||
Reference in New Issue
Block a user