diff src/testdir/test_listchars.vim @ 29090:9b292596a332 v8.2.5066

patch 8.2.5066: timer_create is not available on every Mac system Commit: https://github.com/vim/vim/commit/aca12fd89b082dd9cc12ae085a84f1805747bbdf Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 7 10:16:15 2022 +0100 patch 8.2.5066: timer_create is not available on every Mac system Problem: Timer_create is not available on every Mac system. (Hisashi T Fujinaka) Solution: Adjust #ifdef.
author Bram Moolenaar <Bram@vim.org>
date Tue, 07 Jun 2022 11:30:04 +0200
parents c75f70257cf5
children f08ed0738f7a
line wrap: on
line diff
--- a/src/testdir/test_listchars.vim
+++ b/src/testdir/test_listchars.vim
@@ -132,7 +132,7 @@ func Test_listchars()
 	      \ 'h<<<<<<<<<<<$',
 	      \ '<<<<<<<<<<<<$',
 	      \ '>>>>0xx0<<<<$',
-              \ '$'
+        \ '$'
 	      \ ]
   redraw!
   for i in range(1, 5)
@@ -162,7 +162,7 @@ func Test_listchars()
 	      \ ' hyYzZyYzZyY$',
 	      \ 'yYzZyYzZyYj $',
 	      \ 'yYzZ0yY0yYzZ$',
-              \ '$'
+        \ '$'
 	      \ ]
   redraw!
   for i in range(1, 5)
@@ -172,7 +172,133 @@ func Test_listchars()
 
   call assert_equal(expected, split(execute("%list"), "\n"))
 
+  " Test leadmultispace + multispace
+  normal ggdG
+  set listchars=eol:$,multispace:yYzZ,nbsp:S
+  set listchars+=leadmultispace:.-+*
+  set list
+
+  call append(0, [
+	      \ '    ffff    ',
+	      \ '  i i     gg',
+	      \ ' h          ',
+	      \ '          j ',
+	      \ '    0  0    ',
+	      \ ])
+
+  let expected = [
+	      \ '.-+*ffffyYzZ$',
+	      \ '.-i iSyYzZgg$',
+	      \ ' hyYzZyYzZyY$',
+	      \ '.-+*.-+*.-j $',
+	      \ '.-+*0yY0yYzZ$',
+        \ '$'
+	      \ ]
+  redraw!
+  call assert_equal('eol:$,multispace:yYzZ,nbsp:S,leadmultispace:.-+*', &listchars)
+  for i in range(1, 5)
+    call cursor(i, 1)
+    call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
+  endfor
+
+  call assert_equal(expected, split(execute("%list"), "\n"))
+
+  " Test leadmultispace without multispace
+  normal ggdG
+  set listchars-=multispace:yYzZ
+  set listchars+=space:+,trail:>,eol:$
+  set list
+
+  call append(0, [
+	      \ '    ffff    ',
+	      \ '  i i     gg',
+	      \ ' h          ',
+	      \ '          j ',
+	      \ '    0  0    ',
+	      \ ])
+
+  let expected = [
+	      \ '.-+*ffff>>>>$',
+	      \ '.-i+i+++++gg$',
+	      \ '+h>>>>>>>>>>$',
+	      \ '.-+*.-+*.-j>$',
+	      \ '.-+*0++0>>>>$',
+        \ '$',
+	      \ ]
+
+  redraw!
+  call assert_equal('eol:$,nbsp:S,leadmultispace:.-+*,space:+,trail:>,eol:$', &listchars)
+  for i in range(1, 5)
+    call cursor(i, 1)
+    call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
+  endfor
+
+  call assert_equal(expected, split(execute("%list"), "\n"))
+
+  " Test leadmultispace only
+  normal ggdG
+  set listchars&
+  set listchars=leadmultispace:.-+*
+  set list
+
+  call append(0, [
+	      \ '    ffff    ',
+	      \ '  i i     gg',
+	      \ ' h          ',
+	      \ '          j ',
+	      \ '    0  0    ',
+	      \ ])
+
+  let expected = [
+	      \ '.-+*ffff    ',
+	      \ '.-i i     gg',
+	      \ ' h          ',
+	      \ '.-+*.-+*.-j ',
+	      \ '.-+*0  0    ',
+        \ ' ',
+	      \ ]
+  redraw!
+  call assert_equal('leadmultispace:.-+*', &listchars)
+  for i in range(1, 5)
+    call cursor(i, 1)
+    call assert_equal([expected[i - 1]], ScreenLines(i, 12))
+  endfor
+  call assert_equal(expected, split(execute("%list"), "\n"))
+
+  " Test leadmultispace and lead and space
+  normal ggdG
+  set listchars&
+  set listchars+=lead:<,space:-
+  set listchars+=leadmultispace:.-+*
+  set list
+
+  call append(0, [
+	      \ '    ffff    ',
+	      \ '  i i     gg',
+	      \ ' h          ',
+	      \ '          j ',
+	      \ '    0  0    ',
+	      \ ])
+
+  let expected = [
+	      \ '.-+*ffff----$',
+	      \ '.-i-i-----gg$',
+	      \ '<h----------$',
+	      \ '.-+*.-+*.-j-$',
+	      \ '.-+*0--0----$',
+        \ '$',
+	      \ ]
+  redraw!
+  call assert_equal('eol:$,lead:<,space:-,leadmultispace:.-+*', &listchars)
+  for i in range(1, 5)
+    call cursor(i, 1)
+    call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
+  endfor
+  call assert_equal(expected, split(execute("%list"), "\n"))
+
   " the last occurrence of 'multispace:' is used
+  set listchars&
+  set listchars+=multispace:yYzZ
   set listchars+=space:x,multispace:XyY
 
   let expected = [
@@ -181,9 +307,10 @@ func Test_listchars()
 	      \ 'xhXyYXyYXyYX$',
 	      \ 'XyYXyYXyYXjx$',
 	      \ 'XyYX0Xy0XyYX$',
-              \ '$'
+        \ '$'
 	      \ ]
   redraw!
+  call assert_equal('eol:$,multispace:yYzZ,space:x,multispace:XyY', &listchars)
   for i in range(1, 5)
     call cursor(i, 1)
     call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
@@ -199,7 +326,7 @@ func Test_listchars()
 	      \ '>h<<<<<<<<<<$',
 	      \ '>>>>>>>>>>j<$',
 	      \ '>>>>0Xy0<<<<$',
-              \ '$'
+        \ '$'
 	      \ ]
   redraw!
   for i in range(1, 5)
@@ -219,7 +346,7 @@ func Test_listchars()
 	      \ '>h<<<<<<<<<<$',
 	      \ '>>>>>>>>>>j<$',
 	      \ '>>>>0xx0<<<<$',
-              \ '$'
+        \ '$'
 	      \ ]
   redraw!
   for i in range(1, 5)
@@ -315,11 +442,13 @@ func Test_listchars_invalid()
   call assert_fails('set listchars=x', 'E474:')
   call assert_fails('set listchars=x', 'E474:')
   call assert_fails('set listchars=multispace', 'E474:')
+  call assert_fails('set listchars=leadmultispace', 'E474:')
 
   " Too short
   call assert_fails('set listchars=space:', 'E474:')
   call assert_fails('set listchars=tab:x', 'E474:')
   call assert_fails('set listchars=multispace:', 'E474:')
+  call assert_fails('set listchars=leadmultispace:', 'E474:')
 
   " One occurrence too short
   call assert_fails('set listchars=space:,space:x', 'E474:')
@@ -328,6 +457,8 @@ func Test_listchars_invalid()
   call assert_fails('set listchars=tab:xx,tab:x', 'E474:')
   call assert_fails('set listchars=multispace:,multispace:x', 'E474:')
   call assert_fails('set listchars=multispace:x,multispace:', 'E474:')
+  call assert_fails('set listchars=leadmultispace:,leadmultispace:x', 'E474:')
+  call assert_fails('set listchars=leadmultispace:x,leadmultispace:', 'E474:')
 
   " Too long
   call assert_fails('set listchars=space:xx', 'E474:')
@@ -340,6 +471,8 @@ func Test_listchars_invalid()
   call assert_fails('set listchars=tab:xx·', 'E474:')
   call assert_fails('set listchars=multispace:·', 'E474:')
   call assert_fails('set listchars=multispace:xxx·', 'E474:')
+  call assert_fails('set listchars=leadmultispace:·', 'E474:')
+  call assert_fails('set listchars=leadmultispace:xxx·', 'E474:')
 
   " Has control character
   call assert_fails("set listchars=space:\x01", 'E474:')
@@ -354,6 +487,10 @@ func Test_listchars_invalid()
   call assert_fails('set listchars=tab:xx\\x01', 'E474:')
   call assert_fails('set listchars=multispace:\\x01', 'E474:')
   call assert_fails('set listchars=multispace:xxx\\x01', 'E474:')
+  call assert_fails("set listchars=leadmultispace:\x01", 'E474:')
+  call assert_fails('set listchars=leadmultispace:\\x01', 'E474:')
+  call assert_fails("set listchars=leadmultispace:xxx\x01", 'E474:')
+  call assert_fails('set listchars=leadmultispace:xxx\\x01', 'E474:')
 
   enew!
   set ambiwidth& listchars& ff&