view src/testdir/test_winbuf_close.vim @ 34336:d2ad8733db75 v9.1.0101

patch 9.1.0101: upper-case of German sharp s should be U+1E9E Commit: https://github.com/vim/vim/commit/bd1232a1faf56b614a1e74c4ce51bc6e0650ae00 Author: glepnir <glephunter@gmail.com> Date: Mon Feb 12 22:14:53 2024 +0100 patch 9.1.0101: upper-case of German sharp s should be U+1E9E Problem: upper-case of ? should be U+1E9E (CAPITAL LETTER SHARP S) (fenuks) Solution: Make gU, ~ and g~ convert the U+00DF LATIN SMALL LETTER SHARP S (?) to U+1E9E LATIN CAPITAL LETTER SHARP S (?), update tests (glepnir) This is part of Unicode 5.1.0 from April 2008, so should be fairly safe to use now and since 2017 is part of the German standard orthography, according to Wikipedia: https://en.wikipedia.org/wiki/Capital_%E1%BA%9E#cite_note-auto-12 There is however one exception: UnicodeData.txt for U+00DF LATIN SMALL LETTER SHARP S does NOT define U+1E9E LATIN CAPITAL LETTER SHARP S as its upper case version. Therefore, toupper() won't be able to convert from lower sharp s to upper case sharp s (the other way around however works, since U+00DF is considered the lower case character of U+1E9E and therefore tolower() works correctly for the upper case version). fixes: #5573 closes: #14018 Signed-off-by: glepnir <glephunter@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 12 Feb 2024 22:45:02 +0100
parents dbec60b8c253
children
line wrap: on
line source

" Test for commands that close windows and/or buffers:
" :quit
" :close
" :hide
" :only
" :sall
" :all
" :ball
" :buf
" :edit
"
func Test_winbuf_close()
  enew | only

  call writefile(['testtext 1'], 'Xtest1', 'D')
  call writefile(['testtext 2'], 'Xtest2', 'D')
  call writefile(['testtext 3'], 'Xtest3', 'D')

  next! Xtest1 Xtest2
  call setline(1, 'testtext 1 1')

  " test for working :n when hidden set
  set hidden
  next
  call assert_equal('Xtest2', bufname('%'))

  " test for failing :rew when hidden not set
  set nohidden
  call setline(1, 'testtext 2 2')
  call assert_fails('rewind', 'E37:')
  call assert_equal('Xtest2', bufname('%'))
  call assert_equal('testtext 2 2', getline(1))

  " test for working :rew when hidden set
  set hidden
  rewind
  call assert_equal('Xtest1', bufname('%'))
  call assert_equal('testtext 1 1', getline(1))

  " test for :all keeping a buffer when it's modified
  set nohidden
  call setline(1, 'testtext 1 1 1')
  split
  next Xtest2 Xtest3
  all
  1wincmd w
  call assert_equal('Xtest1', bufname('%'))
  call assert_equal('testtext 1 1 1', getline(1))

  " test abandoning changed buffer, should be unloaded even when 'hidden' set
  set hidden
  call setline(1, 'testtext 1 1 1 1')
  quit!
  call assert_equal('Xtest2', bufname('%'))
  call assert_equal('testtext 2 2', getline(1))
  unhide
  call assert_equal('Xtest2', bufname('%'))
  call assert_equal('testtext 2 2', getline(1))

  " test ":hide" hides anyway when 'hidden' not set
  set nohidden
  call setline(1, 'testtext 2 2 2')
  hide
  call assert_equal('Xtest3', bufname('%'))
  call assert_equal('testtext 3', getline(1))

  " test ":edit" failing in modified buffer when 'hidden' not set
  call setline(1, 'testtext 3 3')
  call assert_fails('edit Xtest1', 'E37:')
  call assert_equal('Xtest3', bufname('%'))
  call assert_equal('testtext 3 3', getline(1))

  " test ":edit" working in modified buffer when 'hidden' set
  set hidden
  edit Xtest1
  call assert_equal('Xtest1', bufname('%'))
  call assert_equal('testtext 1', getline(1))

  " test ":close" not hiding when 'hidden' not set in modified buffer
  split Xtest3
  set nohidden
  call setline(1, 'testtext 3 3 3')
  call assert_fails('close', 'E37:')
  call assert_equal('Xtest3', bufname('%'))
  call assert_equal('testtext 3 3 3', getline(1))

  " test ":close!" does hide when 'hidden' not set in modified buffer;
  call setline(1, 'testtext 3 3 3 3')
  close!
  call assert_equal('Xtest1', bufname('%'))
  call assert_equal('testtext 1', getline(1))

  set nohidden

  " test ":all!" hides changed buffer
  split Xtest4
  call setline(1, 'testtext 4')
  all!
  1wincmd w
  call assert_equal('Xtest2', bufname('%'))
  call assert_equal('testtext 2 2 2', getline(1))

  " test ":q!" and hidden buffer.
  bwipe! Xtest1 Xtest2 Xtest3 Xtest4
  split Xtest1
  wincmd w
  bwipe!
  set modified
  bot split Xtest2
  set modified
  bot split Xtest3
  set modified
  wincmd t
  hide
  call assert_equal('Xtest2', bufname('%'))
  quit!
  call assert_equal('Xtest3', bufname('%'))
  call assert_fails('silent! quit!', 'E37:')
  call assert_equal('Xtest1', bufname('%'))
endfunc

" Test that ":close" will respect 'winfixheight' when possible.
func Test_winfixheight_on_close()
  set nosplitbelow nosplitright

  split | split | vsplit

  $wincmd w
  setlocal winfixheight
  let l:height = winheight(0)

  3close

  call assert_equal(l:height, winheight(0))

  %bwipeout!
  setlocal nowinfixheight splitbelow& splitright&
endfunc

" Test that ":close" will respect 'winfixwidth' when possible.
func Test_winfixwidth_on_close()
  set nosplitbelow nosplitright

  vsplit | vsplit | split

  $wincmd w
  setlocal winfixwidth
  let l:width = winwidth(0)

  3close

  call assert_equal(l:width, winwidth(0))

  %bwipeout!
  setlocal nowinfixwidth splitbelow& splitright&
endfunction

" Test that 'winfixheight' will be respected even there is non-leaf frame
func Test_winfixheight_non_leaf_frame()
  vsplit
  botright 11new
  let l:wid = win_getid()
  setlocal winfixheight
  call assert_equal(11, winheight(l:wid))
  botright new
  bwipe!
  call assert_equal(11, winheight(l:wid))
  %bwipe!
endf

" Test that 'winfixwidth' will be respected even there is non-leaf frame
func Test_winfixwidth_non_leaf_frame()
  split
  topleft 11vnew
  let l:wid = win_getid()
  setlocal winfixwidth
  call assert_equal(11, winwidth(l:wid))
  topleft new
  bwipe!
  call assert_equal(11, winwidth(l:wid))
  %bwipe!
endf

func Test_tabwin_close()
  enew
  let l:wid = win_getid()
  tabedit
  call win_execute(l:wid, 'close')
  " Should not crash.
  call assert_true(v:true)

  " This tests closing a window in another tab, while leaving the tab open
  " i.e. two windows in another tab.
  tabedit
  let w:this_win = 42
  new
  let othertab_wid = win_getid()
  tabprevious
  call win_execute(othertab_wid, 'q')
  " drawing the tabline helps check that the other tab's windows and buffers
  " are still valid
  redrawtabline
  " but to be certain, ensure we can focus the other tab too
  tabnext
  call assert_equal(42, w:this_win)

  bwipe!
endfunc

" Test when closing a split window (above/below) restores space to the window
" below when 'noequalalways' and 'splitright' are set.
func Test_window_close_splitright_noequalalways()
  set noequalalways
  set splitright
  new
  let w1 = win_getid()
  new
  let w2 = win_getid()
  execute "normal \<c-w>b"
  let h = winheight(0)
  let w = win_getid()
  new
  q
  call assert_equal(h, winheight(0), "Window height does not match eight before opening and closing another window")
  call assert_equal(w, win_getid(), "Did not return to original window after opening and closing a window")
endfunc

" vim: shiftwidth=2 sts=2 expandtab