mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
commit
e1d81178cc
@ -7586,27 +7586,35 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
|
||||
* happen when using 'sts' and 'linebreak'. */
|
||||
if (vcol >= start_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? */
|
||||
if (mode == BACKSPACE_WORD && !ascii_isspace(gchar_cursor())) {
|
||||
mode = BACKSPACE_WORD_NOT_SPACE;
|
||||
temp = vim_iswordc(gchar_cursor());
|
||||
// Delete upto starting point, start of line or previous word.
|
||||
} else {
|
||||
int cclass = 0, prev_cclass = 0;
|
||||
|
||||
if (has_mbyte) {
|
||||
cclass = mb_get_class(get_cursor_pos_ptr());
|
||||
}
|
||||
/* end of word? */
|
||||
else if (mode == BACKSPACE_WORD_NOT_SPACE
|
||||
&& (ascii_isspace(cc = gchar_cursor())
|
||||
|| vim_iswordc(cc) != temp)) {
|
||||
if (!revins_on)
|
||||
inc_cursor();
|
||||
else if (State & REPLACE_FLAG)
|
||||
do {
|
||||
if (!revins_on) { // put cursor on char to be deleted
|
||||
dec_cursor();
|
||||
}
|
||||
cc = gchar_cursor();
|
||||
// look multi-byte character class
|
||||
if (has_mbyte) {
|
||||
prev_cclass = cclass;
|
||||
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();
|
||||
} else if (State & REPLACE_FLAG) {
|
||||
dec_cursor();
|
||||
}
|
||||
break;
|
||||
}
|
||||
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.lnum != Insstart_orig.lnum
|
||||
|| curwin->w_cursor.col != Insstart_orig.col)));
|
||||
did_backspace = TRUE;
|
||||
}
|
||||
did_si = FALSE;
|
||||
can_si = FALSE;
|
||||
can_si_back = FALSE;
|
||||
if (curwin->w_cursor.col <= 1)
|
||||
did_ai = FALSE;
|
||||
/*
|
||||
* It's a little strange to put backspaces into the redo
|
||||
* buffer, but it makes auto-indent a lot easier to deal
|
||||
* with.
|
||||
*/
|
||||
did_backspace = true;
|
||||
}
|
||||
did_si = false;
|
||||
can_si = false;
|
||||
can_si_back = false;
|
||||
if (curwin->w_cursor.col <= 1) {
|
||||
did_ai = false;
|
||||
}
|
||||
// It's a little strange to put backspaces into the redo
|
||||
// buffer, but it makes auto-indent a lot easier to deal
|
||||
// with.
|
||||
AppendCharToRedobuff(c);
|
||||
|
||||
/* If deleted before the insertion point, adjust it */
|
||||
|
@ -444,7 +444,7 @@ static int included_patches[] = {
|
||||
// 683 NA
|
||||
682,
|
||||
// 681 NA
|
||||
// 680,
|
||||
680,
|
||||
// 679 NA
|
||||
// 678 NA
|
||||
// 677 NA
|
||||
|
24
test/functional/legacy/erasebackword_spec.lua
Normal file
24
test/functional/legacy/erasebackword_spec.lua
Normal file
@ -0,0 +1,24 @@
|
||||
-- Test for CTRL-W in Insert mode
|
||||
|
||||
local helpers = require('test.functional.helpers')
|
||||
local clear, feed, expect = helpers.clear, helpers.feed, helpers.expect
|
||||
|
||||
describe('CTRL-W in Insert mode', function()
|
||||
setup(clear)
|
||||
|
||||
it('works for multi-byte characters', function()
|
||||
|
||||
for i = 1, 6 do
|
||||
feed('o wwwこんにちわ世界ワールドvim ' .. string.rep('<C-w>', i) .. '<esc>')
|
||||
end
|
||||
|
||||
expect([[
|
||||
|
||||
wwwこんにちわ世界ワールド
|
||||
wwwこんにちわ世界
|
||||
wwwこんにちわ
|
||||
www
|
||||
|
||||
]])
|
||||
end)
|
||||
end)
|
Loading…
Reference in New Issue
Block a user