mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.680
Problem: CTRL-W in Insert mode does not work well for multi-byte
characters.
Solution: Use mb_get_class(). (Yasuhiro Matsumoto)
310f2d59b2
This commit is contained in:
parent
bcbcf235f6
commit
f1aec23c09
@ -7586,27 +7586,35 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
|
|||||||
* happen when using 'sts' and 'linebreak'. */
|
* happen when using 'sts' and 'linebreak'. */
|
||||||
if (vcol >= start_vcol)
|
if (vcol >= start_vcol)
|
||||||
ins_bs_one(&vcol);
|
ins_bs_one(&vcol);
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Delete upto starting point, start of line or previous word.
|
|
||||||
*/
|
|
||||||
else do {
|
|
||||||
if (!revins_on) /* put cursor on char to be deleted */
|
|
||||||
dec_cursor();
|
|
||||||
|
|
||||||
/* start of word? */
|
// Delete upto starting point, start of line or previous word.
|
||||||
if (mode == BACKSPACE_WORD && !ascii_isspace(gchar_cursor())) {
|
} else {
|
||||||
mode = BACKSPACE_WORD_NOT_SPACE;
|
int cclass = 0, prev_cclass = 0;
|
||||||
temp = vim_iswordc(gchar_cursor());
|
|
||||||
|
if (has_mbyte) {
|
||||||
|
cclass = mb_get_class(get_cursor_pos_ptr());
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
if (!revins_on) { // put cursor on char to be deleted
|
||||||
|
dec_cursor();
|
||||||
}
|
}
|
||||||
/* end of word? */
|
cc = gchar_cursor();
|
||||||
else if (mode == BACKSPACE_WORD_NOT_SPACE
|
// look multi-byte character class
|
||||||
&& (ascii_isspace(cc = gchar_cursor())
|
if (has_mbyte) {
|
||||||
|| vim_iswordc(cc) != temp)) {
|
prev_cclass = cclass;
|
||||||
if (!revins_on)
|
cclass = mb_get_class(get_cursor_pos_ptr());
|
||||||
|
}
|
||||||
|
if (mode == BACKSPACE_WORD && !ascii_isspace(cc)) { // start of word?
|
||||||
|
mode = BACKSPACE_WORD_NOT_SPACE;
|
||||||
|
temp = vim_iswordc(cc);
|
||||||
|
} else if (mode == BACKSPACE_WORD_NOT_SPACE
|
||||||
|
&& ((ascii_isspace(cc) || vim_iswordc(cc) != temp)
|
||||||
|
|| prev_cclass != cclass)) { // end of word?
|
||||||
|
if (!revins_on) {
|
||||||
inc_cursor();
|
inc_cursor();
|
||||||
else if (State & REPLACE_FLAG)
|
} else if (State & REPLACE_FLAG) {
|
||||||
dec_cursor();
|
dec_cursor();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (State & REPLACE_FLAG)
|
if (State & REPLACE_FLAG)
|
||||||
@ -7639,18 +7647,18 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
|
|||||||
(curwin->w_cursor.col > mincol
|
(curwin->w_cursor.col > mincol
|
||||||
&& (curwin->w_cursor.lnum != Insstart_orig.lnum
|
&& (curwin->w_cursor.lnum != Insstart_orig.lnum
|
||||||
|| curwin->w_cursor.col != Insstart_orig.col)));
|
|| curwin->w_cursor.col != Insstart_orig.col)));
|
||||||
did_backspace = TRUE;
|
}
|
||||||
|
did_backspace = true;
|
||||||
}
|
}
|
||||||
did_si = FALSE;
|
did_si = false;
|
||||||
can_si = FALSE;
|
can_si = false;
|
||||||
can_si_back = FALSE;
|
can_si_back = false;
|
||||||
if (curwin->w_cursor.col <= 1)
|
if (curwin->w_cursor.col <= 1) {
|
||||||
did_ai = FALSE;
|
did_ai = false;
|
||||||
/*
|
}
|
||||||
* It's a little strange to put backspaces into the redo
|
// It's a little strange to put backspaces into the redo
|
||||||
* buffer, but it makes auto-indent a lot easier to deal
|
// buffer, but it makes auto-indent a lot easier to deal
|
||||||
* with.
|
// with.
|
||||||
*/
|
|
||||||
AppendCharToRedobuff(c);
|
AppendCharToRedobuff(c);
|
||||||
|
|
||||||
/* If deleted before the insertion point, adjust it */
|
/* If deleted before the insertion point, adjust it */
|
||||||
|
@ -444,7 +444,7 @@ static int included_patches[] = {
|
|||||||
// 683 NA
|
// 683 NA
|
||||||
682,
|
682,
|
||||||
// 681 NA
|
// 681 NA
|
||||||
// 680,
|
680,
|
||||||
// 679 NA
|
// 679 NA
|
||||||
// 678 NA
|
// 678 NA
|
||||||
// 677 NA
|
// 677 NA
|
||||||
|
Loading…
Reference in New Issue
Block a user