Skip to content

Commit abc39ab

Browse files
committed
patch 8.0.0394: tabs are not aligned when scrolling horizontally
Problem: Tabs are not aligned when scrolling horizontally and a Tab doesn't fit. (Axel Bender) Solution: Handle a Tab as a not fitting character. (Christian Brabandt) Also fix that ":redraw" does not scroll horizontally to show the cursor. And fix the test that depended on the old behavior.
1 parent 98e83b2 commit abc39ab

File tree

6 files changed

+60
-5
lines changed

6 files changed

+60
-5
lines changed

src/ex_docmd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9812,6 +9812,7 @@ ex_redraw(exarg_T *eap)
98129812

98139813
RedrawingDisabled = 0;
98149814
p_lz = FALSE;
9815+
validate_cursor();
98159816
update_topline();
98169817
update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0);
98179818
#ifdef FEAT_TITLE

src/screen.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,10 +3429,13 @@ win_line(
34293429
#else
34303430
--ptr;
34313431
#endif
3432+
/* If the character fits on the screen, don't need to skip it.
3433+
* Except for a TAB. */
3434+
if ((
34323435
#ifdef FEAT_MBYTE
3433-
/* character fits on the screen, don't need to skip it */
3434-
if ((*mb_ptr2cells)(ptr) >= c && col == 0)
3436+
(*mb_ptr2cells)(ptr) >= c ||
34353437
#endif
3438+
*ptr == TAB) && col == 0)
34363439
n_skip = v - vcol;
34373440
}
34383441

src/testdir/test_breakindent.vim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ endfunction
274274

275275
function Test_breakindent16()
276276
" Check that overlong lines are indented correctly.
277-
" TODO: currently it does not fail even when the bug is not fixed.
278277
let s:input=""
279278
call s:test_windows('setl breakindent briopt=min:0 ts=4')
280279
call setline(1, "\t".repeat("1234567890", 10))
@@ -283,16 +282,16 @@ function Test_breakindent16()
283282
redraw!
284283
let lines=s:screen_lines(1,10)
285284
let expect=[
286-
\ " 123456",
287285
\ " 789012",
288286
\ " 345678",
287+
\ " 901234",
289288
\ ]
290289
call s:compare_lines(expect, lines)
291290
let lines=s:screen_lines(4,10)
292291
let expect=[
293-
\ " 901234",
294292
\ " 567890",
295293
\ " 123456",
294+
\ " 7890 ",
296295
\ ]
297296
call s:compare_lines(expect, lines)
298297
call s:close_windows()

src/testdir/test_listlbr.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,19 @@ func Test_list_with_listchars()
217217
call s:compare_lines(expect, lines)
218218
call s:close_windows()
219219
endfunc
220+
221+
func Test_list_with_tab_and_skipping_first_chars()
222+
call s:test_windows('setl list listchars=tab:>- ts=70 nowrap')
223+
call setline(1, ["iiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa"])
224+
call cursor(4,64)
225+
norm! 2zl
226+
let lines = s:screen_lines([1, 4], winwidth(0))
227+
let expect = [
228+
\ "---------------aaaaa",
229+
\ "---------------aaaaa",
230+
\ "---------------aaaaa",
231+
\ "iiiiiiiii>-----aaaaa",
232+
\ ]
233+
call s:compare_lines(expect, lines)
234+
call s:close_windows()
235+
endfu

src/testdir/test_listlbr_utf8.vim

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,37 @@ func Test_multibyte_wrap_and_breakat()
220220
call s:compare_lines(expect, lines)
221221
call s:close_windows('setl brk&vim')
222222
endfunc
223+
224+
func Test_chinese_char_on_wrap_column()
225+
call s:test_windows("setl nolbr wrap sbr=")
226+
syntax off
227+
call setline(1, [
228+
\ 'aaaaaaaaaaaaaaaaaaa中'.
229+
\ 'aaaaaaaaaaaaaaaaa中'.
230+
\ 'aaaaaaaaaaaaaaaaa中'.
231+
\ 'aaaaaaaaaaaaaaaaa中'.
232+
\ 'aaaaaaaaaaaaaaaaa中'.
233+
\ 'aaaaaaaaaaaaaaaaa中'.
234+
\ 'aaaaaaaaaaaaaaaaa中'.
235+
\ 'aaaaaaaaaaaaaaaaa中'.
236+
\ 'aaaaaaaaaaaaaaaaa中'.
237+
\ 'aaaaaaaaaaaaaaaaa中'.
238+
\ 'hello'])
239+
call cursor(1,1)
240+
norm! $
241+
redraw!
242+
let expect=[
243+
\ '中aaaaaaaaaaaaaaaaa>',
244+
\ '中aaaaaaaaaaaaaaaaa>',
245+
\ '中aaaaaaaaaaaaaaaaa>',
246+
\ '中aaaaaaaaaaaaaaaaa>',
247+
\ '中aaaaaaaaaaaaaaaaa>',
248+
\ '中aaaaaaaaaaaaaaaaa>',
249+
\ '中aaaaaaaaaaaaaaaaa>',
250+
\ '中aaaaaaaaaaaaaaaaa>',
251+
\ '中aaaaaaaaaaaaaaaaa>',
252+
\ '中hello ']
253+
let lines = s:screen_lines([1, 10], winwidth(0))
254+
call s:compare_lines(expect, lines)
255+
call s:close_windows()
256+
endfu

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
394,
767769
/**/
768770
393,
769771
/**/

0 commit comments

Comments
 (0)