neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

test_mksession_utf8.vim (3088B)


      1 " Test for :mksession, :mkview and :loadview in utf-8 encoding
      2 
      3 set encoding=utf-8
      4 scriptencoding utf-8
      5 
      6 source check.vim
      7 CheckFeature mksession
      8 
      9 func Test_mksession_utf8()
     10  tabnew
     11  let wrap_save = &wrap
     12  set sessionoptions=buffers splitbelow fileencoding=utf-8
     13  call setline(1, [
     14    \   'start:',
     15    \   'no multibyte chAracter',
     16    \   '	one leaDing tab',
     17    \   '    four leadinG spaces',
     18    \   'two		consecutive tabs',
     19    \   'two	tabs	in one line',
     20    \   'one … multibyteCharacter',
     21    \   'a “b” two multiByte characters',
     22    \   '“c”1€ three mulTibyte characters'
     23    \ ])
     24  let tmpfile = tempname()
     25  exec 'w! ' . tmpfile
     26  /^start:
     27  set wrap
     28  vsplit
     29  norm! j16|
     30  split
     31  norm! j16|
     32  split
     33  norm! j16|
     34  split
     35  norm! j8|
     36  split
     37  norm! j8|
     38  split
     39  norm! j16|
     40  split
     41  norm! j16|
     42  split
     43  norm! j16|
     44  wincmd l
     45 
     46  set nowrap
     47  /^start:
     48  norm! j16|3zl
     49  split
     50  norm! j016|3zl
     51  split
     52  norm! j016|3zl
     53  split
     54  norm! j08|3zl
     55  split
     56  norm! j08|3zl
     57  split
     58  norm! j016|3zl
     59  split
     60  norm! j016|3zl
     61  split
     62  norm! j016|3zl
     63  split
     64  call wincol()
     65  mksession! test_mks.out
     66  let li = filter(readfile('test_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"')
     67  let expected =<< trim [DATA]
     68    normal! 016|
     69    normal! 016|
     70    normal! 016|
     71    normal! 08|
     72    normal! 08|
     73    normal! 016|
     74    normal! 016|
     75    normal! 016|
     76      exe 'normal! ' . s:c . '|zs' . 16 . '|'
     77      normal! 016|
     78      exe 'normal! ' . s:c . '|zs' . 16 . '|'
     79      normal! 016|
     80      exe 'normal! ' . s:c . '|zs' . 16 . '|'
     81      normal! 016|
     82      exe 'normal! ' . s:c . '|zs' . 8 . '|'
     83      normal! 08|
     84      exe 'normal! ' . s:c . '|zs' . 8 . '|'
     85      normal! 08|
     86      exe 'normal! ' . s:c . '|zs' . 16 . '|'
     87      normal! 016|
     88      exe 'normal! ' . s:c . '|zs' . 16 . '|'
     89      normal! 016|
     90      exe 'normal! ' . s:c . '|zs' . 16 . '|'
     91      normal! 016|
     92      exe 'normal! ' . s:c . '|zs' . 16 . '|'
     93      normal! 016|
     94  [DATA]
     95 
     96  call assert_equal(expected, li)
     97  tabclose!
     98 
     99  call delete('test_mks.out')
    100  call delete(tmpfile)
    101  let &wrap = wrap_save
    102  set sessionoptions& splitbelow& fileencoding&
    103 endfunc
    104 
    105 func Test_session_multibyte_mappings()
    106  " some characters readily available on european keyboards,
    107  " as well as characters containing 0x80 or 0x9b bytes
    108  let entries = [
    109        \ ['n', 'ç', 'ç'],
    110        \ ['n', 'º', 'º'],
    111        \ ['n', '¡', '¡'],
    112        \ ['n', '<M-ç>', '<M-ç>'],
    113        \ ['n', '<M-º>', '<M-º>'],
    114        \ ['n', '<M-¡>', '<M-¡>'],
    115        \ ['n', '…', 'ě'],
    116        \ ['n', 'ě', '…'],
    117        \ ['n', '<M-…>', '<M-ě>'],
    118        \ ['n', '<M-ě>', '<M-…>'],
    119        \ ]
    120  for entry in entries
    121    exe entry[0] .. 'map ' .. entry[1] .. ' ' .. entry[2]
    122  endfor
    123 
    124  mkvimrc Xtestvimrc
    125 
    126  nmapclear
    127 
    128  for entry in entries
    129    call assert_equal('', maparg(entry[1], entry[0]))
    130  endfor
    131 
    132  source Xtestvimrc
    133 
    134  for entry in entries
    135    call assert_equal(entry[2], maparg(entry[1], entry[0]))
    136  endfor
    137 
    138  nmapclear
    139 
    140  call delete('Xtestvimrc')
    141 endfunc
    142 
    143 " vim: shiftwidth=2 sts=2 expandtab