Skip to content

Commit 05aacec

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.0320: Wrong cursor position after using setcellwidths()
Problem: Wrong cursor position after using setcellwidths(). Solution: Invalidate cursor position in addition to redrawing. (zeertzjq) closes: #14545 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 3d93630 commit 05aacec

5 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/mbyte.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5733,6 +5733,7 @@ f_setcellwidths(typval_T *argvars, typval_T *rettv UNUSED)
57335733
}
57345734

57355735
vim_free(cw_table_save);
5736+
changed_window_setting_all();
57365737
redraw_all_later(UPD_CLEAR);
57375738
}
57385739

src/move.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,19 @@ changed_window_setting_buf(buf_T *buf)
677677
}
678678
#endif
679679

680+
/*
681+
* Call changed_window_setting_win() for every window.
682+
*/
683+
void
684+
changed_window_setting_all(void)
685+
{
686+
tabpage_T *tp;
687+
win_T *wp;
688+
689+
FOR_ALL_TAB_WINDOWS(tp, wp)
690+
changed_window_setting_win(wp);
691+
}
692+
680693
/*
681694
* Set wp->w_topline to a certain number.
682695
*/

src/proto/move.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ void check_cursor_moved(win_T *wp);
99
void changed_window_setting(void);
1010
void changed_window_setting_win(win_T *wp);
1111
void changed_window_setting_buf(buf_T *buf);
12+
void changed_window_setting_all(void);
1213
void set_topline(win_T *wp, linenr_T lnum);
1314
void changed_cline_bef_curs(void);
1415
void changed_cline_bef_curs_win(win_T *wp);

src/testdir/test_utf8.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ func Test_screenchar_utf8()
170170
endfunc
171171

172172
func Test_setcellwidths()
173+
new
173174
call setcellwidths([
174175
\ [0x1330, 0x1330, 2],
175176
\ [9999, 10000, 1],
@@ -212,6 +213,18 @@ func Test_setcellwidths()
212213
" Ambiguous width chars
213214
call assert_equal(2, strwidth("\u00A1"))
214215
call assert_equal(2, strwidth("\u2010"))
216+
217+
call setcellwidths([])
218+
call setline(1, repeat("\u2103", 10))
219+
normal! $
220+
redraw
221+
call assert_equal((aw == 'single') ? 10 : 19, wincol())
222+
call setcellwidths([[0x2103, 0x2103, 1]])
223+
redraw
224+
call assert_equal(10, wincol())
225+
call setcellwidths([[0x2103, 0x2103, 2]])
226+
redraw
227+
call assert_equal(19, wincol())
215228
endfor
216229
set ambiwidth& isprint&
217230

@@ -245,6 +258,7 @@ func Test_setcellwidths()
245258
set listchars&
246259
set fillchars&
247260
call setcellwidths([])
261+
bwipe!
248262
endfunc
249263

250264
func Test_getcellwidths()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
320,
707709
/**/
708710
319,
709711
/**/

0 commit comments

Comments
 (0)