forked from aniani/vim
		
	patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Problem: "g$" causes scroll if half a double width char is visible. Solution: Advance to the last fully visible character. (closes #8254)
This commit is contained in:
		
							
								
								
									
										11
									
								
								src/normal.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/normal.c
									
									
									
									
									
								
							| @@ -6144,6 +6144,17 @@ nv_g_cmd(cmdarg_T *cap) | |||||||
| 		i = curwin->w_leftcol + curwin->w_width - col_off - 1; | 		i = curwin->w_leftcol + curwin->w_width - col_off - 1; | ||||||
| 		coladvance((colnr_T)i); | 		coladvance((colnr_T)i); | ||||||
|  |  | ||||||
|  | 		// if the character doesn't fit move one back | ||||||
|  | 		if (curwin->w_cursor.col > 0 | ||||||
|  | 				       && (*mb_ptr2cells)(ml_get_cursor()) > 1) | ||||||
|  | 		{ | ||||||
|  | 		    colnr_T vcol; | ||||||
|  |  | ||||||
|  | 		    getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &vcol); | ||||||
|  | 		    if (vcol >= curwin->w_leftcol + curwin->w_width - col_off) | ||||||
|  | 			--curwin->w_cursor.col; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		// Make sure we stick in this column. | 		// Make sure we stick in this column. | ||||||
| 		validate_virtcol(); | 		validate_virtcol(); | ||||||
| 		curwin->w_curswant = curwin->w_virtcol; | 		curwin->w_curswant = curwin->w_virtcol; | ||||||
|   | |||||||
| @@ -2201,9 +2201,9 @@ func Test_normal33_g_cmd2() | |||||||
|   %d |   %d | ||||||
|   15vsp |   15vsp | ||||||
|   set wrap listchars= sbr= |   set wrap listchars= sbr= | ||||||
|   let lineA='abcdefghijklmnopqrstuvwxyz' |   let lineA = 'abcdefghijklmnopqrstuvwxyz' | ||||||
|   let lineB='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' |   let lineB = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||||||
|   let lineC='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' |   let lineC = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' | ||||||
|   $put =lineA |   $put =lineA | ||||||
|   $put =lineB |   $put =lineB | ||||||
|  |  | ||||||
| @@ -2238,6 +2238,28 @@ func Test_normal33_g_cmd2() | |||||||
|   call assert_equal('l', getreg(0)) |   call assert_equal('l', getreg(0)) | ||||||
|   call assert_beeps('normal 5g$') |   call assert_beeps('normal 5g$') | ||||||
|  |  | ||||||
|  |   " Test for g$ with double-width character half displayed | ||||||
|  |   vsplit | ||||||
|  |   9wincmd | | ||||||
|  |   setlocal nowrap nonumber | ||||||
|  |   call setline(2, 'asdfasdfヨ') | ||||||
|  |   2 | ||||||
|  |   normal 0g$ | ||||||
|  |   call assert_equal(8, col('.')) | ||||||
|  |   10wincmd | | ||||||
|  |   normal 0g$ | ||||||
|  |   call assert_equal(9, col('.')) | ||||||
|  |  | ||||||
|  |   setlocal signcolumn=yes | ||||||
|  |   11wincmd | | ||||||
|  |   normal 0g$ | ||||||
|  |   call assert_equal(8, col('.')) | ||||||
|  |   12wincmd | | ||||||
|  |   normal 0g$ | ||||||
|  |   call assert_equal(9, col('.')) | ||||||
|  |  | ||||||
|  |   close | ||||||
|  |  | ||||||
|   " Test for g_ |   " Test for g_ | ||||||
|   call assert_beeps('normal! 100g_') |   call assert_beeps('normal! 100g_') | ||||||
|   call setline(2, ['  foo  ', '  foobar  ']) |   call setline(2, ['  foo  ', '  foobar  ']) | ||||||
|   | |||||||
| @@ -750,6 +750,8 @@ static char *(features[]) = | |||||||
|  |  | ||||||
| static int included_patches[] = | static int included_patches[] = | ||||||
| {   /* Add new patch number below this line */ | {   /* Add new patch number below this line */ | ||||||
|  | /**/ | ||||||
|  |     2904, | ||||||
| /**/ | /**/ | ||||||
|     2903, |     2903, | ||||||
| /**/ | /**/ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user