092_mksession_cursor_cols_utf8_spec.lua (3183B)
1 -- Tests if :mksession saves cursor columns correctly in presence of tab and 2 -- multibyte characters when fileencoding=utf-8. 3 -- 4 -- Same as legacy test 93 but using UTF-8 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 UTF-8', 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 “b” two multiByte characters 30 “c”1€ three mulTibyte characters]]) 31 -- This test requires the buffer to correspond to a file on disk, here named 32 -- "test.in", because otherwise :mksession won't write out the cursor column 33 -- info needed for verification. 34 feed_command('write! test.in') 35 36 feed_command('set sessionoptions=buffers splitbelow fileencoding=utf-8') 37 38 -- Move the cursor through the buffer lines and position it with "|". Using 39 -- :split after every normal mode command is a trick to have multiple 40 -- cursors on the screen that can all be stored in the session file. 41 feed_command('/^start:') 42 feed_command('vsplit') 43 feed('j16|:split<cr>') 44 feed('j16|:split<cr>') 45 feed('j16|:split<cr>') 46 feed('j8|:split<cr>') 47 feed('j8|:split<cr>') 48 feed('j16|:split<cr>') 49 feed('j16|:split<cr>') 50 feed('j16|') 51 52 -- Again move the cursor through the buffer and position it with "|". This 53 -- time also perform a horizontal scroll at every step. 54 feed_command('wincmd l') 55 feed_command('/^start:') 56 feed_command('set nowrap') 57 feed('j16|3zl:split<cr>') 58 feed('j016|3zl:split<cr>') 59 feed('j016|3zl:split<cr>') 60 feed('j08|3zl:split<cr>') 61 feed('j08|3zl:split<cr>') 62 feed('j016|3zl:split<cr>') 63 feed('j016|3zl:split<cr>') 64 feed('j016|3zl:split<cr>') 65 66 -- Create the session file, read it back in, and prepare for verification. 67 feed_command('mksession! test.out') 68 feed_command('new test.out') 69 feed_command([[v/\(^ *normal! 0\|^ *exe 'normal!\)/d]]) 70 71 -- Assert buffer contents. 72 expect([[ 73 normal! 016| 74 normal! 016| 75 normal! 016| 76 normal! 08| 77 normal! 08| 78 normal! 016| 79 normal! 016| 80 normal! 016| 81 exe 'normal! ' . s:c . '|zs' . 16 . '|' 82 normal! 016| 83 exe 'normal! ' . s:c . '|zs' . 16 . '|' 84 normal! 016| 85 exe 'normal! ' . s:c . '|zs' . 16 . '|' 86 normal! 016| 87 exe 'normal! ' . s:c . '|zs' . 8 . '|' 88 normal! 08| 89 exe 'normal! ' . s:c . '|zs' . 8 . '|' 90 normal! 08| 91 exe 'normal! ' . s:c . '|zs' . 16 . '|' 92 normal! 016| 93 exe 'normal! ' . s:c . '|zs' . 16 . '|' 94 normal! 016| 95 exe 'normal! ' . s:c . '|zs' . 16 . '|' 96 normal! 016| 97 exe 'normal! ' . s:c . '|zs' . 16 . '|' 98 normal! 016|]]) 99 end) 100 end)