diff options
author | Justin Gassner <justin.gassner@web.de> | 2016-01-22 11:04:05 +0100 |
---|---|---|
committer | Justin Gassner <justin.gassner@web.de> | 2016-01-22 11:55:00 +0100 |
commit | f1aec23c0904fd5055f555a545adc5b801fff872 (patch) | |
tree | 69ce54b816208712fc0dfa7794cc847da5b03c41 /src/nvim/edit.c | |
parent | bcbcf235f61bd75f965f35897784ea618fe7acb8 (diff) | |
download | rneovim-f1aec23c0904fd5055f555a545adc5b801fff872.tar.gz rneovim-f1aec23c0904fd5055f555a545adc5b801fff872.tar.bz2 rneovim-f1aec23c0904fd5055f555a545adc5b801fff872.zip |
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)
https://github.com/vim/vim/commit/310f2d59b2b20c642088feb5e6dfe323cc570923
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r-- | src/nvim/edit.c | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index ccfc9b4803..dbbcf4f1b9 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -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()); + } + do { + if (!revins_on) { // put cursor on char to be deleted + dec_cursor(); } - /* end of word? */ - else if (mode == BACKSPACE_WORD_NOT_SPACE - && (ascii_isspace(cc = gchar_cursor()) - || vim_iswordc(cc) != temp)) { - if (!revins_on) + 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) + } 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_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_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 */ |