aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2014-10-10 15:37:12 -0400
committerJustin M. Keyes <justinkz@gmail.com>2014-10-10 15:37:12 -0400
commit867aff3d2d59e84caa914c84063862b07d306f4c (patch)
treec6ddea6e012019f962bf63b659f819dc3c0c7f6b
parent7ff71b5790e942ecf9fad4093d2cbb0abac0a591 (diff)
parentd62545e5ba65853ae556993a3e219df23e561b2c (diff)
downloadrneovim-867aff3d2d59e84caa914c84063862b07d306f4c.tar.gz
rneovim-867aff3d2d59e84caa914c84063862b07d306f4c.tar.bz2
rneovim-867aff3d2d59e84caa914c84063862b07d306f4c.zip
Merge pull request #1280 from splinterofchaos/visual-mb
vim-patch:7.4.408
-rw-r--r--src/nvim/ops.c14
-rw-r--r--src/nvim/testdir/Makefile3
-rw-r--r--src/nvim/testdir/test_utf8.in18
-rw-r--r--src/nvim/testdir/test_utf8.ok4
-rw-r--r--src/nvim/version.c2
5 files changed, 39 insertions, 2 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index ed2a82d55c..e74fcef8d9 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -512,6 +512,20 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def
}
}
+ if (has_mbyte && spaces > 0) {
+ // Avoid starting halfway a multi-byte character.
+ if (b_insert) {
+ int off = (*mb_head_off)(oldp, oldp + offset + spaces);
+ spaces -= off;
+ count -= off;
+ } else {
+ int off = (*mb_off_next)(oldp, oldp + offset);
+ offset += off;
+ spaces = 0;
+ count = 0;
+ }
+ }
+
newp = (char_u *) xmalloc((size_t)(STRLEN(oldp) + s_len + count + 1));
/* copy up to shifted part */
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index 9f04f880b5..521fbc19cf 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -35,7 +35,8 @@ SCRIPTS := test_autoformat_join.out \
test_listlbr.out test_listlbr_utf8.out \
test_changelist.out \
test_breakindent.out \
- test_insertcount.out
+ test_insertcount.out \
+ test_utf8.out
SCRIPTS_GUI := test16.out
diff --git a/src/nvim/testdir/test_utf8.in b/src/nvim/testdir/test_utf8.in
new file mode 100644
index 0000000000..e8d23c4be8
--- /dev/null
+++ b/src/nvim/testdir/test_utf8.in
@@ -0,0 +1,18 @@
+Tests for Unicode manipulations
+
+STARTTEST
+:so small.vim
+:set encoding=utf-8
+:" Visual block Insert adjusts for multi-byte char
+:new
+:call setline(1, ["aaa", "あああ", "bbb"])
+:exe ":norm! gg0l\<C-V>jjIx\<Esc>"
+:let r = getline(1, '$')
+:
+:bwipeout!
+:$put=r
+:call garbagecollect(1)
+:/^start:/,$wq! test.out
+ENDTEST
+
+start:
diff --git a/src/nvim/testdir/test_utf8.ok b/src/nvim/testdir/test_utf8.ok
new file mode 100644
index 0000000000..c5bed54856
--- /dev/null
+++ b/src/nvim/testdir/test_utf8.ok
@@ -0,0 +1,4 @@
+start:
+axaa
+xあああ
+bxbb
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 16be84a17c..331d80b512 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -224,7 +224,7 @@ static int included_patches[] = {
411,
410,
//409 NA
- //408,
+ 408,
407,
//406,
405,