view src/testdir/test_retab.vim @ 12170:1345621ecdfb v8.0.0965

patch 8.0.0965: not restoring cursor shape after it was set in a terminal commit https://github.com/vim/vim/commit/3eee06e7d4c3a8e2dbb2577a1eef0e0f108e0288 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 19 19:40:50 2017 +0200 patch 8.0.0965: not restoring cursor shape after it was set in a terminal Problem: The cursor shape is not reset after it was changed in a terminal. Solution: Request the original cursor shape and restore it. Add t_RS. Do not add t_SH for now, it does not work properly.
author Christian Brabandt <cb@256bit.org>
date Sat, 19 Aug 2017 19:45:04 +0200
parents 91444fa276eb
children 08940efa6b4e
line wrap: on
line source

" Test :retab
func SetUp()
  new
  call setline(1, "\ta  \t    b        c    ")
endfunc

func TearDown()
  bwipe!
endfunc

func Retab(bang, n)
  let l:old_tabstop = &tabstop
  let l:old_line = getline(1)
  exe "retab" . a:bang . a:n
  let l:line = getline(1)
  call setline(1, l:old_line)
  if a:n > 0
    " :retab changes 'tabstop' to n with argument n > 0.
    call assert_equal(a:n, &tabstop)
    exe 'set tabstop=' . l:old_tabstop
  else
    " :retab does not change 'tabstop' with empty or n <= 0.
    call assert_equal(l:old_tabstop, &tabstop)
  endif
  return l:line
endfunc

func Test_retab()
  set tabstop=8 noexpandtab
  call assert_equal("\ta\t    b        c    ",            Retab('',  ''))
  call assert_equal("\ta\t    b        c    ",            Retab('',  0))
  call assert_equal("\ta\t    b        c    ",            Retab('',  8))
  call assert_equal("\ta\t    b\t     c\t  ",             Retab('!', ''))
  call assert_equal("\ta\t    b\t     c\t  ",             Retab('!', 0))
  call assert_equal("\ta\t    b\t     c\t  ",             Retab('!', 8))

  call assert_equal("\t\ta\t\t\tb        c    ",          Retab('',  4))
  call assert_equal("\t\ta\t\t\tb\t\t c\t  ",             Retab('!', 4))

  call assert_equal("        a\t\tb        c    ",        Retab('',  10))
  call assert_equal("        a\t\tb        c    ",        Retab('!', 10))

  set tabstop=8 expandtab
  call assert_equal("        a           b        c    ", Retab('',  ''))
  call assert_equal("        a           b        c    ", Retab('',  0))
  call assert_equal("        a           b        c    ", Retab('',  8))
  call assert_equal("        a           b        c    ", Retab('!', ''))
  call assert_equal("        a           b        c    ", Retab('!', 0))
  call assert_equal("        a           b        c    ", Retab('!', 8))

  call assert_equal("        a           b        c    ", Retab(' ', 4))
  call assert_equal("        a           b        c    ", Retab('!', 4))

  call assert_equal("        a           b        c    ", Retab(' ', 10))
  call assert_equal("        a           b        c    ", Retab('!', 10))

  set tabstop=4 noexpandtab
  call assert_equal("\ta\t\tb        c    ",              Retab('',  ''))
  call assert_equal("\ta\t\tb\t\t c\t  ",                 Retab('!', ''))
  call assert_equal("\t a\t\t\tb        c    ",           Retab('',  3))
  call assert_equal("\t a\t\t\tb\t\t\tc\t  ",             Retab('!', 3))
  call assert_equal("    a\t  b        c    ",            Retab('',  5))
  call assert_equal("    a\t  b\t\t c\t ",                Retab('!', 5))

  set tabstop=4 expandtab
  call assert_equal("    a       b        c    ",         Retab('',  ''))
  call assert_equal("    a       b        c    ",         Retab('!', ''))
  call assert_equal("    a       b        c    ",         Retab('',  3))
  call assert_equal("    a       b        c    ",         Retab('!', 3))
  call assert_equal("    a       b        c    ",         Retab('',  5))
  call assert_equal("    a       b        c    ",         Retab('!', 5))
endfunc

func Test_retab_error()
  call assert_fails('retab -1',  'E487:')
  call assert_fails('retab! -1', 'E487:')
endfunc