aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2017-02-10 09:18:11 -0500
committerJames McCoy <jamessan@jamessan.com>2017-02-10 09:29:16 -0500
commit91efe96b9661369add378499fd4fc918f624d9a9 (patch)
tree5f09cac8a1e9c70af43ede9849905e7cded552f7
parent7ed1422521eeebdd57bc79a55f4385767976a9f2 (diff)
downloadrneovim-91efe96b9661369add378499fd4fc918f624d9a9.tar.gz
rneovim-91efe96b9661369add378499fd4fc918f624d9a9.tar.bz2
rneovim-91efe96b9661369add378499fd4fc918f624d9a9.zip
vim-patch:7.4.1948
Problem: Using Ctrl-A with double-byte encoding may result in garbled text. Solution: Skip to the start of a character. (Hirohito Higashi) https://github.com/vim/vim/commit/ad5ca9bc1e7145474adb082775a805f1731e9e37
-rw-r--r--src/nvim/ops.c19
-rw-r--r--src/nvim/version.c2
2 files changed, 16 insertions, 5 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 9a01891483..d58c8700ca 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -4455,12 +4455,14 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
if (dobin) {
while (col > 0 && ascii_isbdigit(ptr[col])) {
col--;
+ col -= utf_head_off(ptr, ptr + col);
}
}
if (dohex) {
while (col > 0 && ascii_isxdigit(ptr[col])) {
col--;
+ col -= utf_head_off(ptr, ptr + col);
}
}
if (dobin
@@ -4468,6 +4470,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
&& !((col > 0
&& (ptr[col] == 'X' || ptr[col] == 'x')
&& ptr[col - 1] == '0'
+ && !utf_head_off(ptr, ptr + col - 1)
&& ascii_isxdigit(ptr[col + 1])))) {
// In case of binary/hexadecimal pattern overlap match, rescan
@@ -4475,6 +4478,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
while (col > 0 && ascii_isdigit(ptr[col])) {
col--;
+ col -= utf_head_off(ptr, ptr + col);
}
}
@@ -4482,14 +4486,17 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
&& col > 0
&& (ptr[col] == 'X' || ptr[col] == 'x')
&& ptr[col - 1] == '0'
+ && !utf_head_off(ptr, ptr + col - 1)
&& ascii_isxdigit(ptr[col + 1]))
|| (dobin
&& col > 0
&& (ptr[col] == 'B' || ptr[col] == 'b')
&& ptr[col - 1] == '0'
+ && !utf_head_off(ptr, ptr + col - 1)
&& ascii_isbdigit(ptr[col + 1]))) {
// Found hexadecimal or binary number, move to its start.
col--;
+ col -= utf_head_off(ptr, ptr + col);
} else {
// Search forward and then backward to find the start of number.
col = pos->col;
@@ -4511,15 +4518,18 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
if (visual) {
while (ptr[col] != NUL && length > 0 && !ascii_isdigit(ptr[col])
&& !(doalp && ASCII_ISALPHA(ptr[col]))) {
- col++;
- length--;
+ int mb_len = MB_PTR2LEN(ptr + col);
+
+ col += mb_len;
+ length -= mb_len;
}
if (length == 0) {
goto theend;
}
- if (col > pos->col && ptr[col - 1] == '-') {
+ if (col > pos->col && ptr[col - 1] == '-'
+ && !utf_head_off(ptr, ptr + col - 1)) {
negative = true;
was_positive = false;
}
@@ -4565,7 +4575,8 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
endpos = curwin->w_cursor;
curwin->w_cursor.col = col;
} else {
- if (col > 0 && ptr[col - 1] == '-' && !visual) {
+ if (col > 0 && ptr[col - 1] == '-'
+ && !utf_head_off(ptr, ptr + col - 1) && !visual) {
// negative number
col--;
negative = true;
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 6188bec91f..a958ff1fd9 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -492,7 +492,7 @@ static int included_patches[] = {
// 1951 NA
1950,
1949,
- // 1948,
+ 1948,
// 1947 NA
// 1946 NA
// 1945 NA