blob: 8ffbba2a1c17206122d5db6d75c265cb8083e15f [file] [log] [blame]
Bram Moolenaareca626f2016-12-01 18:47:38 +01001" Test for :mksession, :mkview and :loadview in utf-8 encoding
2
3set encoding=utf-8
4scriptencoding utf-8
5
6if !has('multi_byte') || !has('mksession')
7 finish
8endif
9
10func Test_mksession_utf8()
11 tabnew
12 let wrap_save = &wrap
13 set sessionoptions=buffers splitbelow fileencoding=utf-8
14 call setline(1, [
15 \ 'start:',
16 \ 'no multibyte chAracter',
17 \ ' one leaDing tab',
18 \ ' four leadinG spaces',
19 \ 'two consecutive tabs',
20 \ 'two tabs in one line',
21 \ 'one … multibyteCharacter',
22 \ 'a “b” two multiByte characters',
23 \ '“c”1€ three mulTibyte characters'
24 \ ])
25 let tmpfile = tempname()
26 exec 'w! ' . tmpfile
27 /^start:
28 set wrap
29 vsplit
30 norm! j16|
31 split
32 norm! j16|
33 split
34 norm! j16|
35 split
36 norm! j8|
37 split
38 norm! j8|
39 split
40 norm! j16|
41 split
42 norm! j16|
43 split
44 norm! j16|
45 wincmd l
46
47 set nowrap
48 /^start:
49 norm! j16|3zl
50 split
51 norm! j016|3zl
52 split
53 norm! j016|3zl
54 split
55 norm! j08|3zl
56 split
57 norm! j08|3zl
58 split
59 norm! j016|3zl
60 split
61 norm! j016|3zl
62 split
63 norm! j016|3zl
64 split
65 call wincol()
66 mksession! test_mks.out
67 let li = filter(readfile('test_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"')
68 let expected = [
69 \ 'normal! 016|',
70 \ 'normal! 016|',
71 \ 'normal! 016|',
72 \ 'normal! 08|',
73 \ 'normal! 08|',
74 \ 'normal! 016|',
75 \ 'normal! 016|',
76 \ 'normal! 016|',
77 \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
78 \ " normal! 016|",
79 \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
80 \ " normal! 016|",
81 \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
82 \ " normal! 016|",
83 \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'",
84 \ " normal! 08|",
85 \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'",
86 \ " normal! 08|",
87 \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
88 \ " normal! 016|",
89 \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
90 \ " normal! 016|",
91 \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
92 \ " normal! 016|",
93 \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
94 \ " normal! 016|"
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
Bram Moolenaar2c997d72017-11-23 22:52:09 +0100102 set sessionoptions& splitbelow& fileencoding&
Bram Moolenaareca626f2016-12-01 18:47:38 +0100103endfunc
104
105" vim: shiftwidth=2 sts=2 expandtab