mirror of
https://github.com/neovim/neovim.git
synced 2025-11-23 18:46:38 +00:00
Merge #11750 from janlazo/vim-8.2.0146
vim-patch:8.1.2245,8.2.{146,147}
This commit is contained in:
@@ -1802,9 +1802,10 @@ char_u *ml_get(linenr_T lnum)
|
|||||||
/*
|
/*
|
||||||
* Return pointer to position "pos".
|
* Return pointer to position "pos".
|
||||||
*/
|
*/
|
||||||
char_u *ml_get_pos(pos_T *pos)
|
char_u *ml_get_pos(const pos_T *pos)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
return ml_get_buf(curbuf, pos->lnum, FALSE) + pos->col;
|
return ml_get_buf(curbuf, pos->lnum, false) + pos->col;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -760,7 +760,7 @@ static void normal_get_additional_char(NormalState *s)
|
|||||||
// because if it's put back with vungetc() it's too late to apply
|
// because if it's put back with vungetc() it's too late to apply
|
||||||
// mapping.
|
// mapping.
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
while (enc_utf8 && lang && (s->c = vpeekc()) > 0
|
while (lang && (s->c = vpeekc()) > 0
|
||||||
&& (s->c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) {
|
&& (s->c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) {
|
||||||
s->c = plain_vgetc();
|
s->c = plain_vgetc();
|
||||||
if (!utf_iscomposing(s->c)) {
|
if (!utf_iscomposing(s->c)) {
|
||||||
@@ -1711,14 +1711,13 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Include the trailing byte of a multi-byte char. */
|
// Include the trailing byte of a multi-byte char.
|
||||||
if (has_mbyte && oap->inclusive) {
|
if (oap->inclusive) {
|
||||||
int l;
|
const int l = utfc_ptr2len(ml_get_pos(&oap->end));
|
||||||
|
if (l > 1) {
|
||||||
l = (*mb_ptr2len)(ml_get_pos(&oap->end));
|
|
||||||
if (l > 1)
|
|
||||||
oap->end.col += l - 1;
|
oap->end.col += l - 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
curwin->w_set_curswant = true;
|
curwin->w_set_curswant = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1846,10 +1845,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
restart_edit = 0;
|
restart_edit = 0;
|
||||||
|
|
||||||
// Restore linebreak, so that when the user edits it looks as before.
|
// Restore linebreak, so that when the user edits it looks as before.
|
||||||
if (curwin->w_p_lbr != lbr_saved) {
|
|
||||||
curwin->w_p_lbr = lbr_saved;
|
curwin->w_p_lbr = lbr_saved;
|
||||||
get_op_vcol(oap, redo_VIsual_mode, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset finish_op now, don't want it set inside edit().
|
// Reset finish_op now, don't want it set inside edit().
|
||||||
finish_op = false;
|
finish_op = false;
|
||||||
@@ -1935,10 +1931,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
restart_edit = 0;
|
restart_edit = 0;
|
||||||
|
|
||||||
// Restore linebreak, so that when the user edits it looks as before.
|
// Restore linebreak, so that when the user edits it looks as before.
|
||||||
if (curwin->w_p_lbr != lbr_saved) {
|
|
||||||
curwin->w_p_lbr = lbr_saved;
|
curwin->w_p_lbr = lbr_saved;
|
||||||
get_op_vcol(oap, redo_VIsual_mode, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
op_insert(oap, cap->count1);
|
op_insert(oap, cap->count1);
|
||||||
|
|
||||||
@@ -1964,10 +1957,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
CancelRedo();
|
CancelRedo();
|
||||||
} else {
|
} else {
|
||||||
// Restore linebreak, so that when the user edits it looks as before.
|
// Restore linebreak, so that when the user edits it looks as before.
|
||||||
if (curwin->w_p_lbr != lbr_saved) {
|
|
||||||
curwin->w_p_lbr = lbr_saved;
|
curwin->w_p_lbr = lbr_saved;
|
||||||
get_op_vcol(oap, redo_VIsual_mode, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
op_replace(oap, cap->nchar);
|
op_replace(oap, cap->nchar);
|
||||||
}
|
}
|
||||||
@@ -2906,17 +2896,17 @@ static void find_end_of_word(pos_T *pos)
|
|||||||
*/
|
*/
|
||||||
static int get_mouse_class(char_u *p)
|
static int get_mouse_class(char_u *p)
|
||||||
{
|
{
|
||||||
int c;
|
if (MB_BYTE2LEN(p[0]) > 1) {
|
||||||
|
|
||||||
if (has_mbyte && MB_BYTE2LEN(p[0]) > 1)
|
|
||||||
return mb_get_class(p);
|
return mb_get_class(p);
|
||||||
|
}
|
||||||
|
|
||||||
c = *p;
|
const int c = *p;
|
||||||
if (c == ' ' || c == '\t')
|
if (c == ' ' || c == '\t') {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
if (vim_iswordc(c))
|
if (vim_iswordc(c)) {
|
||||||
return 2;
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There are a few special cases where we want certain combinations of
|
* There are a few special cases where we want certain combinations of
|
||||||
@@ -4916,9 +4906,8 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
*p++ = '\\';
|
*p++ = '\\';
|
||||||
/* When current byte is a part of multibyte character, copy all
|
/* When current byte is a part of multibyte character, copy all
|
||||||
* bytes of that character. */
|
* bytes of that character. */
|
||||||
if (has_mbyte) {
|
const size_t len = (size_t)(utfc_ptr2len(ptr) - 1);
|
||||||
size_t len = (size_t)((*mb_ptr2len)(ptr) - 1);
|
for (size_t i = 0; i < len && n > 0; i++, n--) {
|
||||||
for (size_t i = 0; i < len && n > 0; ++i, --n)
|
|
||||||
*p++ = *ptr++;
|
*p++ = *ptr++;
|
||||||
}
|
}
|
||||||
*p++ = *ptr++;
|
*p++ = *ptr++;
|
||||||
@@ -4930,11 +4919,11 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
* Execute the command.
|
* Execute the command.
|
||||||
*/
|
*/
|
||||||
if (cmdchar == '*' || cmdchar == '#') {
|
if (cmdchar == '*' || cmdchar == '#') {
|
||||||
if (!g_cmd && (
|
if (!g_cmd
|
||||||
has_mbyte ? vim_iswordp(mb_prevptr(get_cursor_line_ptr(), ptr)) :
|
&& vim_iswordp(mb_prevptr(get_cursor_line_ptr(), ptr))) {
|
||||||
vim_iswordc(ptr[-1])))
|
|
||||||
STRCAT(buf, "\\>");
|
STRCAT(buf, "\\>");
|
||||||
/* put pattern in search history */
|
}
|
||||||
|
// put pattern in search history
|
||||||
init_history();
|
init_history();
|
||||||
add_to_history(HIST_SEARCH, (char_u *)buf, true, NUL);
|
add_to_history(HIST_SEARCH, (char_u *)buf, true, NUL);
|
||||||
(void)normal_search(cap, cmdchar == '*' ? '/' : '?', (char_u *)buf, 0,
|
(void)normal_search(cap, cmdchar == '*' ? '/' : '?', (char_u *)buf, 0,
|
||||||
@@ -4977,9 +4966,8 @@ get_visual_text (
|
|||||||
*pp = ml_get_pos(&VIsual);
|
*pp = ml_get_pos(&VIsual);
|
||||||
*lenp = (size_t)curwin->w_cursor.col - (size_t)VIsual.col + 1;
|
*lenp = (size_t)curwin->w_cursor.col - (size_t)VIsual.col + 1;
|
||||||
}
|
}
|
||||||
if (has_mbyte)
|
// Correct the length to include the whole last character.
|
||||||
/* Correct the length to include the whole last character. */
|
*lenp += (size_t)(utfc_ptr2len(*pp + (*lenp - 1)) - 1);
|
||||||
*lenp += (size_t)((*mb_ptr2len)(*pp + (*lenp - 1)) - 1);
|
|
||||||
}
|
}
|
||||||
reset_VIsual_and_resel();
|
reset_VIsual_and_resel();
|
||||||
return true;
|
return true;
|
||||||
@@ -5197,11 +5185,7 @@ static void nv_left(cmdarg_T *cap)
|
|||||||
char_u *cp = get_cursor_pos_ptr();
|
char_u *cp = get_cursor_pos_ptr();
|
||||||
|
|
||||||
if (*cp != NUL) {
|
if (*cp != NUL) {
|
||||||
if (has_mbyte) {
|
curwin->w_cursor.col += utfc_ptr2len(cp);
|
||||||
curwin->w_cursor.col += (*mb_ptr2len)(cp);
|
|
||||||
} else {
|
|
||||||
curwin->w_cursor.col++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cap->retval |= CA_NO_ADJ_OP_END;
|
cap->retval |= CA_NO_ADJ_OP_END;
|
||||||
}
|
}
|
||||||
@@ -5859,7 +5843,6 @@ static void nv_replace(cmdarg_T *cap)
|
|||||||
{
|
{
|
||||||
char_u *ptr;
|
char_u *ptr;
|
||||||
int had_ctrl_v;
|
int had_ctrl_v;
|
||||||
long n;
|
|
||||||
|
|
||||||
if (checkclearop(cap->oap))
|
if (checkclearop(cap->oap))
|
||||||
return;
|
return;
|
||||||
@@ -5913,7 +5896,7 @@ static void nv_replace(cmdarg_T *cap)
|
|||||||
/* Abort if not enough characters to replace. */
|
/* Abort if not enough characters to replace. */
|
||||||
ptr = get_cursor_pos_ptr();
|
ptr = get_cursor_pos_ptr();
|
||||||
if (STRLEN(ptr) < (unsigned)cap->count1
|
if (STRLEN(ptr) < (unsigned)cap->count1
|
||||||
|| (has_mbyte && mb_charlen(ptr) < cap->count1)
|
|| (mb_charlen(ptr) < cap->count1)
|
||||||
) {
|
) {
|
||||||
clearopbeep(cap->oap);
|
clearopbeep(cap->oap);
|
||||||
return;
|
return;
|
||||||
@@ -5955,70 +5938,43 @@ static void nv_replace(cmdarg_T *cap)
|
|||||||
NUL, 'r', NUL, had_ctrl_v, cap->nchar);
|
NUL, 'r', NUL, had_ctrl_v, cap->nchar);
|
||||||
|
|
||||||
curbuf->b_op_start = curwin->w_cursor;
|
curbuf->b_op_start = curwin->w_cursor;
|
||||||
if (has_mbyte) {
|
const int old_State = State;
|
||||||
int old_State = State;
|
|
||||||
|
|
||||||
if (cap->ncharC1 != 0)
|
if (cap->ncharC1 != 0) {
|
||||||
AppendCharToRedobuff(cap->ncharC1);
|
AppendCharToRedobuff(cap->ncharC1);
|
||||||
if (cap->ncharC2 != 0)
|
}
|
||||||
|
if (cap->ncharC2 != 0) {
|
||||||
AppendCharToRedobuff(cap->ncharC2);
|
AppendCharToRedobuff(cap->ncharC2);
|
||||||
|
}
|
||||||
|
|
||||||
/* This is slow, but it handles replacing a single-byte with a
|
// This is slow, but it handles replacing a single-byte with a
|
||||||
* multi-byte and the other way around. Also handles adding
|
// multi-byte and the other way around. Also handles adding
|
||||||
* composing characters for utf-8. */
|
// composing characters for utf-8.
|
||||||
for (n = cap->count1; n > 0; --n) {
|
for (long n = cap->count1; n > 0; n--) {
|
||||||
State = REPLACE;
|
State = REPLACE;
|
||||||
if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) {
|
if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) {
|
||||||
int c = ins_copychar(curwin->w_cursor.lnum
|
int c = ins_copychar(curwin->w_cursor.lnum
|
||||||
+ (cap->nchar == Ctrl_Y ? -1 : 1));
|
+ (cap->nchar == Ctrl_Y ? -1 : 1));
|
||||||
if (c != NUL)
|
if (c != NUL) {
|
||||||
ins_char(c);
|
ins_char(c);
|
||||||
else
|
} else {
|
||||||
/* will be decremented further down */
|
// will be decremented further down
|
||||||
++curwin->w_cursor.col;
|
curwin->w_cursor.col++;
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
ins_char(cap->nchar);
|
ins_char(cap->nchar);
|
||||||
|
}
|
||||||
State = old_State;
|
State = old_State;
|
||||||
if (cap->ncharC1 != 0)
|
if (cap->ncharC1 != 0) {
|
||||||
ins_char(cap->ncharC1);
|
ins_char(cap->ncharC1);
|
||||||
if (cap->ncharC2 != 0)
|
}
|
||||||
|
if (cap->ncharC2 != 0) {
|
||||||
ins_char(cap->ncharC2);
|
ins_char(cap->ncharC2);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Replace the characters within one line.
|
|
||||||
*/
|
|
||||||
for (n = cap->count1; n > 0; --n) {
|
|
||||||
/*
|
|
||||||
* Get ptr again, because u_save and/or showmatch() will have
|
|
||||||
* released the line. At the same time we let know that the
|
|
||||||
* line will be changed.
|
|
||||||
*/
|
|
||||||
ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, true);
|
|
||||||
if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) {
|
|
||||||
int c = ins_copychar(curwin->w_cursor.lnum
|
|
||||||
+ (cap->nchar == Ctrl_Y ? -1 : 1));
|
|
||||||
if (c != NUL) {
|
|
||||||
assert(c >= 0 && c <= UCHAR_MAX);
|
|
||||||
ptr[curwin->w_cursor.col] = (char_u)c;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
assert(cap->nchar >= 0 && cap->nchar <= UCHAR_MAX);
|
|
||||||
ptr[curwin->w_cursor.col] = (char_u)cap->nchar;
|
|
||||||
}
|
|
||||||
if (p_sm && msg_silent == 0)
|
|
||||||
showmatch(cap->nchar);
|
|
||||||
++curwin->w_cursor.col;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* mark the buffer as changed and prepare for displaying */
|
|
||||||
changed_bytes(curwin->w_cursor.lnum,
|
|
||||||
(colnr_T)(curwin->w_cursor.col - cap->count1));
|
|
||||||
}
|
}
|
||||||
--curwin->w_cursor.col; /* cursor on the last replaced char */
|
--curwin->w_cursor.col; /* cursor on the last replaced char */
|
||||||
/* if the character on the left of the current cursor is a multi-byte
|
/* if the character on the left of the current cursor is a multi-byte
|
||||||
* character, move two characters left */
|
* character, move two characters left */
|
||||||
if (has_mbyte)
|
|
||||||
mb_adjust_cursor();
|
mb_adjust_cursor();
|
||||||
curbuf->b_op_end = curwin->w_cursor;
|
curbuf->b_op_end = curwin->w_cursor;
|
||||||
curwin->w_set_curswant = true;
|
curwin->w_set_curswant = true;
|
||||||
@@ -7365,9 +7321,8 @@ static void adjust_cursor(oparg_T *oap)
|
|||||||
&& (!VIsual_active || *p_sel == 'o')
|
&& (!VIsual_active || *p_sel == 'o')
|
||||||
&& !virtual_active() && (ve_flags & VE_ONEMORE) == 0
|
&& !virtual_active() && (ve_flags & VE_ONEMORE) == 0
|
||||||
) {
|
) {
|
||||||
--curwin->w_cursor.col;
|
curwin->w_cursor.col--;
|
||||||
/* prevent cursor from moving on the trail byte */
|
// prevent cursor from moving on the trail byte
|
||||||
if (has_mbyte)
|
|
||||||
mb_adjust_cursor();
|
mb_adjust_cursor();
|
||||||
oap->inclusive = true;
|
oap->inclusive = true;
|
||||||
}
|
}
|
||||||
@@ -7395,10 +7350,7 @@ static void adjust_for_sel(cmdarg_T *cap)
|
|||||||
{
|
{
|
||||||
if (VIsual_active && cap->oap->inclusive && *p_sel == 'e'
|
if (VIsual_active && cap->oap->inclusive && *p_sel == 'e'
|
||||||
&& gchar_cursor() != NUL && lt(VIsual, curwin->w_cursor)) {
|
&& gchar_cursor() != NUL && lt(VIsual, curwin->w_cursor)) {
|
||||||
if (has_mbyte)
|
|
||||||
inc_cursor();
|
inc_cursor();
|
||||||
else
|
|
||||||
++curwin->w_cursor.col;
|
|
||||||
cap->oap->inclusive = false;
|
cap->oap->inclusive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7988,9 +7940,7 @@ static void get_op_vcol(
|
|||||||
oap->motion_type = kMTBlockWise;
|
oap->motion_type = kMTBlockWise;
|
||||||
|
|
||||||
// prevent from moving onto a trail byte
|
// prevent from moving onto a trail byte
|
||||||
if (has_mbyte) {
|
|
||||||
mark_mb_adjustpos(curwin->w_buffer, &oap->end);
|
mark_mb_adjustpos(curwin->w_buffer, &oap->end);
|
||||||
}
|
|
||||||
|
|
||||||
getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, &oap->end_vcol);
|
getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, &oap->end_vcol);
|
||||||
if (!redo_VIsual_busy) {
|
if (!redo_VIsual_busy) {
|
||||||
|
|||||||
@@ -357,16 +357,12 @@ static void shift_block(oparg_T *oap, int amount)
|
|||||||
colnr_T ws_vcol = bd.start_vcol - bd.pre_whitesp;
|
colnr_T ws_vcol = bd.start_vcol - bd.pre_whitesp;
|
||||||
char_u * old_textstart = bd.textstart;
|
char_u * old_textstart = bd.textstart;
|
||||||
if (bd.startspaces) {
|
if (bd.startspaces) {
|
||||||
if (has_mbyte) {
|
if (utfc_ptr2len(bd.textstart) == 1) {
|
||||||
if ((*mb_ptr2len)(bd.textstart) == 1) {
|
|
||||||
bd.textstart++;
|
bd.textstart++;
|
||||||
} else {
|
} else {
|
||||||
ws_vcol = 0;
|
ws_vcol = 0;
|
||||||
bd.startspaces = 0;
|
bd.startspaces = 0;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
bd.textstart++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (; ascii_iswhite(*bd.textstart); ) {
|
for (; ascii_iswhite(*bd.textstart); ) {
|
||||||
// TODO: is passing bd.textstart for start of the line OK?
|
// TODO: is passing bd.textstart for start of the line OK?
|
||||||
@@ -1215,9 +1211,7 @@ static void stuffescaped(const char *arg, int literally)
|
|||||||
|
|
||||||
/* stuff a single special character */
|
/* stuff a single special character */
|
||||||
if (*arg != NUL) {
|
if (*arg != NUL) {
|
||||||
const int c = (has_mbyte
|
const int c = mb_cptr2char_adv((const char_u **)&arg);
|
||||||
? mb_cptr2char_adv((const char_u **)&arg)
|
|
||||||
: (uint8_t)(*arg++));
|
|
||||||
if (literally && ((c < ' ' && c != TAB) || c == DEL)) {
|
if (literally && ((c < ' ' && c != TAB) || c == DEL)) {
|
||||||
stuffcharReadbuff(Ctrl_V);
|
stuffcharReadbuff(Ctrl_V);
|
||||||
}
|
}
|
||||||
@@ -1389,7 +1383,6 @@ int op_delete(oparg_T *oap)
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_mbyte)
|
|
||||||
mb_adjust_opend(oap);
|
mb_adjust_opend(oap);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1736,7 +1729,6 @@ int op_replace(oparg_T *oap, int c)
|
|||||||
c = NL;
|
c = NL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_mbyte)
|
|
||||||
mb_adjust_opend(oap);
|
mb_adjust_opend(oap);
|
||||||
|
|
||||||
if (u_save((linenr_T)(oap->start.lnum - 1),
|
if (u_save((linenr_T)(oap->start.lnum - 1),
|
||||||
@@ -2012,16 +2004,15 @@ void op_tilde(oparg_T *oap)
|
|||||||
* Returns TRUE if some character was changed.
|
* Returns TRUE if some character was changed.
|
||||||
*/
|
*/
|
||||||
static int swapchars(int op_type, pos_T *pos, int length)
|
static int swapchars(int op_type, pos_T *pos, int length)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
int todo;
|
|
||||||
int did_change = 0;
|
int did_change = 0;
|
||||||
|
|
||||||
for (todo = length; todo > 0; --todo) {
|
for (int todo = length; todo > 0; todo--) {
|
||||||
if (has_mbyte) {
|
const int len = utfc_ptr2len(ml_get_pos(pos));
|
||||||
int len = (*mb_ptr2len)(ml_get_pos(pos));
|
|
||||||
|
|
||||||
/* we're counting bytes, not characters */
|
// we're counting bytes, not characters
|
||||||
if (len > 0)
|
if (len > 0) {
|
||||||
todo -= len - 1;
|
todo -= len - 1;
|
||||||
}
|
}
|
||||||
did_change |= swapchar(op_type, pos);
|
did_change |= swapchar(op_type, pos);
|
||||||
@@ -3052,7 +3043,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
|
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
|
||||||
|
|
||||||
// move to start of next multi-byte character
|
// move to start of next multi-byte character
|
||||||
curwin->w_cursor.col += (*mb_ptr2len)(get_cursor_pos_ptr());
|
curwin->w_cursor.col += utfc_ptr2len(get_cursor_pos_ptr());
|
||||||
col++;
|
col++;
|
||||||
} else {
|
} else {
|
||||||
getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);
|
getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);
|
||||||
@@ -3615,7 +3606,7 @@ dis_msg(
|
|||||||
while (*p != NUL
|
while (*p != NUL
|
||||||
&& !(*p == ESC && skip_esc && *(p + 1) == NUL)
|
&& !(*p == ESC && skip_esc && *(p + 1) == NUL)
|
||||||
&& (n -= ptr2cells(p)) >= 0) {
|
&& (n -= ptr2cells(p)) >= 0) {
|
||||||
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) {
|
if ((l = utfc_ptr2len(p)) > 1) {
|
||||||
msg_outtrans_len(p, l);
|
msg_outtrans_len(p, l);
|
||||||
p += l;
|
p += l;
|
||||||
} else
|
} else
|
||||||
@@ -4414,7 +4405,10 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum,
|
|||||||
char_u *line;
|
char_u *line;
|
||||||
char_u *prev_pstart;
|
char_u *prev_pstart;
|
||||||
char_u *prev_pend;
|
char_u *prev_pend;
|
||||||
|
const int lbr_saved = curwin->w_p_lbr;
|
||||||
|
|
||||||
|
// Avoid a problem with unwanted linebreaks in block mode.
|
||||||
|
curwin->w_p_lbr = false;
|
||||||
bdp->startspaces = 0;
|
bdp->startspaces = 0;
|
||||||
bdp->endspaces = 0;
|
bdp->endspaces = 0;
|
||||||
bdp->textlen = 0;
|
bdp->textlen = 0;
|
||||||
@@ -4514,6 +4508,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum,
|
|||||||
}
|
}
|
||||||
bdp->textcol = (colnr_T) (pstart - line);
|
bdp->textcol = (colnr_T) (pstart - line);
|
||||||
bdp->textstart = pstart;
|
bdp->textstart = pstart;
|
||||||
|
curwin->w_p_lbr = lbr_saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle the add/subtract operator.
|
/// Handle the add/subtract operator.
|
||||||
|
|||||||
@@ -2243,7 +2243,7 @@ win_line (
|
|||||||
int change_start = MAXCOL; // first col of changed area
|
int change_start = MAXCOL; // first col of changed area
|
||||||
int change_end = -1; // last col of changed area
|
int change_end = -1; // last col of changed area
|
||||||
colnr_T trailcol = MAXCOL; // start of trailing spaces
|
colnr_T trailcol = MAXCOL; // start of trailing spaces
|
||||||
int need_showbreak = false; // overlong line, skip first x chars
|
bool need_showbreak = false; // overlong line, skip first x chars
|
||||||
int line_attr = 0; // attribute for the whole line
|
int line_attr = 0; // attribute for the whole line
|
||||||
int line_attr_lowprio = 0; // low-priority attribute for the line
|
int line_attr_lowprio = 0; // low-priority attribute for the line
|
||||||
matchitem_T *cur; // points to the match list
|
matchitem_T *cur; // points to the match list
|
||||||
@@ -2654,11 +2654,12 @@ win_line (
|
|||||||
else if (fromcol >= 0 && fromcol < vcol)
|
else if (fromcol >= 0 && fromcol < vcol)
|
||||||
fromcol = vcol;
|
fromcol = vcol;
|
||||||
|
|
||||||
/* When w_skipcol is non-zero, first line needs 'showbreak' */
|
// When w_skipcol is non-zero, first line needs 'showbreak'
|
||||||
if (wp->w_p_wrap)
|
if (wp->w_p_wrap) {
|
||||||
need_showbreak = TRUE;
|
need_showbreak = true;
|
||||||
/* When spell checking a word we need to figure out the start of the
|
}
|
||||||
* word and if it's badly spelled or not. */
|
// When spell checking a word we need to figure out the start of the
|
||||||
|
// word and if it's badly spelled or not.
|
||||||
if (has_spell) {
|
if (has_spell) {
|
||||||
size_t len;
|
size_t len;
|
||||||
colnr_T linecol = (colnr_T)(ptr - line);
|
colnr_T linecol = (colnr_T)(ptr - line);
|
||||||
@@ -2975,13 +2976,19 @@ win_line (
|
|||||||
}
|
}
|
||||||
p_extra = NULL;
|
p_extra = NULL;
|
||||||
c_extra = ' ';
|
c_extra = ' ';
|
||||||
n_extra = get_breakindent_win(wp, ml_get_buf(wp->w_buffer, lnum, FALSE));
|
c_final = NUL;
|
||||||
/* Correct end of highlighted area for 'breakindent',
|
n_extra =
|
||||||
required wen 'linebreak' is also set. */
|
get_breakindent_win(wp, ml_get_buf(wp->w_buffer, lnum, false));
|
||||||
if (tocol == vcol)
|
if (wp->w_skipcol > 0 && wp->w_p_wrap) {
|
||||||
|
need_showbreak = false;
|
||||||
|
}
|
||||||
|
// Correct end of highlighted area for 'breakindent',
|
||||||
|
// required wen 'linebreak' is also set.
|
||||||
|
if (tocol == vcol) {
|
||||||
tocol += n_extra;
|
tocol += n_extra;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (draw_state == WL_SBR - 1 && n_extra == 0) {
|
if (draw_state == WL_SBR - 1 && n_extra == 0) {
|
||||||
draw_state = WL_SBR;
|
draw_state = WL_SBR;
|
||||||
@@ -3008,7 +3015,9 @@ win_line (
|
|||||||
c_final = NUL;
|
c_final = NUL;
|
||||||
n_extra = (int)STRLEN(p_sbr);
|
n_extra = (int)STRLEN(p_sbr);
|
||||||
char_attr = win_hl_attr(wp, HLF_AT);
|
char_attr = win_hl_attr(wp, HLF_AT);
|
||||||
|
if (wp->w_skipcol == 0 || !wp->w_p_wrap) {
|
||||||
need_showbreak = false;
|
need_showbreak = false;
|
||||||
|
}
|
||||||
vcol_sbr = vcol + MB_CHARLEN(p_sbr);
|
vcol_sbr = vcol + MB_CHARLEN(p_sbr);
|
||||||
/* Correct end of highlighted area for 'showbreak',
|
/* Correct end of highlighted area for 'showbreak',
|
||||||
* required when 'linebreak' is also set. */
|
* required when 'linebreak' is also set. */
|
||||||
@@ -3285,9 +3294,7 @@ win_line (
|
|||||||
} else {
|
} else {
|
||||||
int c0;
|
int c0;
|
||||||
|
|
||||||
if (p_extra_free != NULL) {
|
|
||||||
XFREE_CLEAR(p_extra_free);
|
XFREE_CLEAR(p_extra_free);
|
||||||
}
|
|
||||||
|
|
||||||
// Get a character from the line itself.
|
// Get a character from the line itself.
|
||||||
c0 = c = *ptr;
|
c0 = c = *ptr;
|
||||||
|
|||||||
@@ -296,3 +296,70 @@ function Test_breakindent16()
|
|||||||
call s:compare_lines(expect, lines)
|
call s:compare_lines(expect, lines)
|
||||||
call s:close_windows()
|
call s:close_windows()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
func Test_breakindent17_vartabs()
|
||||||
|
if !has("vartabs")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let s:input = ""
|
||||||
|
call s:test_windows('setl breakindent list listchars=tab:<-> showbreak=+++')
|
||||||
|
call setline(1, "\t" . repeat('a', 63))
|
||||||
|
vert resize 30
|
||||||
|
norm! 1gg$
|
||||||
|
redraw!
|
||||||
|
let lines = s:screen_lines(1, 30)
|
||||||
|
let expect = [
|
||||||
|
\ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||||
|
\ " +++aaaaaaaaaaaaaaaaaaaaaaa",
|
||||||
|
\ " +++aaaaaaaaaaaaaa ",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows('set breakindent& list& listchars& showbreak&')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_breakindent18_vartabs()
|
||||||
|
if !has("vartabs")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let s:input = ""
|
||||||
|
call s:test_windows('setl breakindent list listchars=tab:<->')
|
||||||
|
call setline(1, "\t" . repeat('a', 63))
|
||||||
|
vert resize 30
|
||||||
|
norm! 1gg$
|
||||||
|
redraw!
|
||||||
|
let lines = s:screen_lines(1, 30)
|
||||||
|
let expect = [
|
||||||
|
\ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||||
|
\ " aaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||||
|
\ " aaaaaaaaaaa ",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows('set breakindent& list& listchars&')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_breakindent19_sbr_nextpage()
|
||||||
|
let s:input = ""
|
||||||
|
call s:test_windows('setl breakindent briopt=shift:2,sbr,min:18 sbr=>')
|
||||||
|
call setline(1, repeat('a', 200))
|
||||||
|
norm! 1gg
|
||||||
|
redraw!
|
||||||
|
let lines = s:screen_lines(1, 20)
|
||||||
|
let expect = [
|
||||||
|
\ "aaaaaaaaaaaaaaaaaaaa",
|
||||||
|
\ "> aaaaaaaaaaaaaaaaaa",
|
||||||
|
\ "> aaaaaaaaaaaaaaaaaa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
" Scroll down one screen line
|
||||||
|
setl scrolloff=5
|
||||||
|
norm! 5gj
|
||||||
|
redraw!
|
||||||
|
let lines = s:screen_lines(1, 20)
|
||||||
|
let expect = [
|
||||||
|
\ "> aaaaaaaaaaaaaaaaaa",
|
||||||
|
\ "> aaaaaaaaaaaaaaaaaa",
|
||||||
|
\ "> aaaaaaaaaaaaaaaaaa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows('set breakindent& briopt& sbr&')
|
||||||
|
endfunc
|
||||||
|
|||||||
@@ -103,6 +103,37 @@ func Test_linebreak_with_conceal()
|
|||||||
call s:close_windows()
|
call s:close_windows()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_linebreak_with_visual_operations()
|
||||||
|
call s:test_windows()
|
||||||
|
let line = '1234567890 2234567890 3234567890'
|
||||||
|
call setline(1, line)
|
||||||
|
|
||||||
|
" yank
|
||||||
|
exec "norm! ^w\<C-V>ey"
|
||||||
|
call assert_equal('2234567890', @@)
|
||||||
|
exec "norm! w\<C-V>ey"
|
||||||
|
call assert_equal('3234567890', @@)
|
||||||
|
|
||||||
|
" increment / decrement
|
||||||
|
exec "norm! ^w\<C-V>\<C-A>w\<C-V>\<C-X>"
|
||||||
|
call assert_equal('1234567890 3234567890 2234567890', getline(1))
|
||||||
|
|
||||||
|
" replace
|
||||||
|
exec "norm! ^w\<C-V>3lraw\<C-V>3lrb"
|
||||||
|
call assert_equal('1234567890 aaaa567890 bbbb567890', getline(1))
|
||||||
|
|
||||||
|
" tilde
|
||||||
|
exec "norm! ^w\<C-V>2l~w\<C-V>2l~"
|
||||||
|
call assert_equal('1234567890 AAAa567890 BBBb567890', getline(1))
|
||||||
|
|
||||||
|
" delete and insert
|
||||||
|
exec "norm! ^w\<C-V>3lc2345\<Esc>w\<C-V>3lc3456\<Esc>"
|
||||||
|
call assert_equal('1234567890 2345567890 3456567890', getline(1))
|
||||||
|
call assert_equal('BBBb', @@)
|
||||||
|
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_virtual_block()
|
func Test_virtual_block()
|
||||||
call s:test_windows('setl sbr=+')
|
call s:test_windows('setl sbr=+')
|
||||||
call setline(1, [
|
call setline(1, [
|
||||||
|
|||||||
Reference in New Issue
Block a user