neovim

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

093_mksession_cursor_cols_latin1_spec.lua (2944B)


      1 -- Tests if :mksession saves cursor columns correctly in presence of tab and
      2 -- multibyte characters when fileencoding=latin1.
      3 --
      4 -- Same as legacy test 92 but using Latin-1 file encoding.
      5 
      6 local n = require('test.functional.testnvim')()
      7 
      8 local feed, insert = n.feed, n.insert
      9 local clear, feed_command, expect = n.clear, n.feed_command, n.expect
     10 
     11 describe('store cursor position in session file in Latin-1', function()
     12  setup(clear)
     13 
     14  teardown(function()
     15    os.remove('test.in')
     16    os.remove('test.out')
     17  end)
     18 
     19  -- luacheck: ignore 621 (Indentation)
     20  it('is working', function()
     21    insert([[
     22      start:
     23      no multibyte chAracter
     24      	one leaDing tab
     25          four leadinG spaces
     26      two		consecutive tabs
     27      two	tabs	in one line
     28      one  multibyteCharacter
     29      a   two multiByte characters
     30      A���  three mulTibyte characters]])
     31    -- Must write buffer to disk for :mksession. See the comments in
     32    -- "092_mksession_cursor_cols_utf8_spec.lua".
     33    feed_command('write! test.in')
     34 
     35    feed_command('set sessionoptions=buffers splitbelow fileencoding=latin1')
     36 
     37    -- Move the cursor through the buffer lines and position it with "|".
     38    feed_command('/^start:')
     39    feed_command('vsplit')
     40    feed('j16|:split<cr>')
     41    feed('j16|:split<cr>')
     42    feed('j16|:split<cr>')
     43    feed('j8|:split<cr>')
     44    feed('j8|:split<cr>')
     45    feed('j16|:split<cr>')
     46    feed('j16|:split<cr>')
     47    feed('j16|')
     48 
     49    -- Again move the cursor through the buffer and position it with "|". This
     50    -- time also perform a horizontal scroll at every step.
     51    feed_command('wincmd l')
     52    feed_command('/^start:')
     53    feed_command('set nowrap')
     54    feed('j16|3zl:split<cr>')
     55    feed('j016|3zl:split<cr>')
     56    feed('j016|3zl:split<cr>')
     57    feed('j08|3zl:split<cr>')
     58    feed('j08|3zl:split<cr>')
     59    feed('j016|3zl:split<cr>')
     60    feed('j016|3zl:split<cr>')
     61    feed('j016|3zl:split<cr>')
     62 
     63    -- Create the session file, read it back in, and prepare for verification.
     64    feed_command('mksession! test.out')
     65    feed_command('new test.out')
     66    feed_command([[v/\(^ *normal! 0\|^ *exe 'normal!\)/d]])
     67 
     68    -- Assert buffer contents.
     69    expect([[
     70      normal! 016|
     71      normal! 016|
     72      normal! 016|
     73      normal! 08|
     74      normal! 08|
     75      normal! 016|
     76      normal! 016|
     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' . 16 . '|'
     83        normal! 016|
     84        exe 'normal! ' . s:c . '|zs' . 8 . '|'
     85        normal! 08|
     86        exe 'normal! ' . s:c . '|zs' . 8 . '|'
     87        normal! 08|
     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        exe 'normal! ' . s:c . '|zs' . 16 . '|'
     95        normal! 016|]])
     96  end)
     97 end)