summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2021-11-04 13:28:29 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-04 13:28:29 +0000
commitaaec1d4fb12efb82b87ad322e95994de77b1a833 (patch)
tree6899cf9b5a4bcfef0fc6092b9a8bd5f7214f38f6
parent4b2c8047679b737dcb0cd15c313ee51553aed617 (diff)
downloadvim-git-aaec1d4fb12efb82b87ad322e95994de77b1a833.tar.gz
patch 8.2.3580: gj does not move properly with a wide characterv8.2.3580
Problem: gj does not move properly with a wide character. Solution: Move one to the right. (Christian Brabandt, closes #8702)
-rw-r--r--src/normal.c9
-rw-r--r--src/testdir/test_normal.vim12
-rw-r--r--src/version.c2
3 files changed, 22 insertions, 1 deletions
diff --git a/src/normal.c b/src/normal.c
index e6b7a8a75..ba3b53b64 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -2530,7 +2530,7 @@ nv_screengo(oparg_T *oap, int dir, long dist)
int col_off1; // margin offset for first screen line
int col_off2; // margin offset for wrapped screen line
int width1; // text width for first screen line
- int width2; // test width for wrapped screen line
+ int width2; // text width for wrapped screen line
oap->motion_type = MCHAR;
oap->inclusive = (curwin->w_curswant == MAXCOL);
@@ -2656,6 +2656,7 @@ nv_screengo(oparg_T *oap, int dir, long dist)
if (curwin->w_cursor.col > 0 && curwin->w_p_wrap)
{
colnr_T virtcol;
+ int c;
/*
* Check for landing on a character that got split at the end of the
@@ -2669,6 +2670,12 @@ nv_screengo(oparg_T *oap, int dir, long dist)
virtcol -= vim_strsize(get_showbreak_value(curwin));
#endif
+ c = (*mb_ptr2char)(ml_get_cursor());
+ if (dir == FORWARD && virtcol < curwin->w_curswant
+ && (curwin->w_curswant <= (colnr_T)width1)
+ && !vim_isprintc(c) && c > 255)
+ oneright();
+
if (virtcol > curwin->w_curswant
&& (curwin->w_curswant < (colnr_T)width1
? (curwin->w_curswant > (colnr_T)width1 / 2)
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index f994f970a..c437315ae 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -3423,4 +3423,16 @@ func Test_normal_count_after_operator()
bw!
endfunc
+func Test_normal_gj_on_extra_wide_char()
+ new | 25vsp
+ let text='1 foooooooo ar e ins‍zwe1 foooooooo ins‍zwei' .
+ \ ' i drei vier fünf sechs sieben acht un zehn elf zwöfl' .
+ \ ' dreizehn v ierzehn fünfzehn'
+ put =text
+ call cursor(2,1)
+ norm! gj
+ call assert_equal([0,2,25,0], getpos('.'))
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 2dd061eda..3d34c035c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3580,
+/**/
3579,
/**/
3578,