summaryrefslogtreecommitdiff
path: root/src/charset.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-01-28 13:48:10 +0100
committerBram Moolenaar <Bram@vim.org>2017-01-28 13:48:10 +0100
commit0c0590d9827cb07a33c1552cb3558b94bddcb4dc (patch)
tree9a4eb2d939907176500b19b938cba106d98bc676 /src/charset.c
parent4bc2f2e9fd73da4ba79cef83e4720e918981c483 (diff)
downloadvim-git-0c0590d9827cb07a33c1552cb3558b94bddcb4dc.tar.gz
patch 8.0.0250: virtcol() does not work well for multi-byte charactersv8.0.0250
Problem: When virtcol() gets a column that is not the first byte of a multi-byte character the result is unpredictable. (Christian Ludwig) Solution: Correct the column to the first byte of a multi-byte character. Change the utf-8 test to new style.
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/charset.c b/src/charset.c
index c047afec7..e766fa5f6 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1296,7 +1296,14 @@ getvcol(
if (pos->col == MAXCOL)
posptr = NULL; /* continue until the NUL */
else
+ {
posptr = ptr + pos->col;
+#ifdef FEAT_MBYTE
+ if (has_mbyte)
+ /* always start on the first byte */
+ posptr -= (*mb_head_off)(line, posptr);
+#endif
+ }
/*
* This function is used very often, do some speed optimizations.