blob: 7a1cedeeaca5747fdd736c748cef4a0548fe6220 [file] [log] [blame]
Bram Moolenaare52702f2020-06-04 18:22:13 +02001scriptencoding utf-8
2
3func Run_cjk_linebreak_after()
4 set textwidth=12
5 for punct in [
6 \ '!', '%', ')', ',', ':', ';', '>', '?', ']', '}', '’', '”', '†', '‡',
7 \ '…', '‰', '‱', '‼', '⁇', '⁈', '⁉', '℃', '℉', '、', '。', '〉', '》',
8 \ '」', '』', '】', '〕', '〗', '〙', '〛', '!', ')', ',', '.', ':',
9 \ ';', '?', ']', '}']
10 call setline('.', '这是一个测试'.punct.'试试 CJK 行禁则补丁。')
11 normal gqq
12 call assert_equal('这是一个测试'.punct, getline(1))
13 %d_
14 endfor
15endfunc
16
17func Test_cjk_linebreak_after()
18 set formatoptions=croqn2mB1j
19 call Run_cjk_linebreak_after()
20endfunc
21
22" TODO: this test fails
23"func Test_cjk_linebreak_after_rigorous()
24" set formatoptions=croqn2mB1j]
25" call Run_cjk_linebreak_after()
26"endfunc
27
28func Run_cjk_linebreak_before()
29 set textwidth=12
30 for punct in [
31 \ '(', '<', '[', '`', '{', '‘', '“', '〈', '《', '「', '『', '【', '〔',
32 \ '〖', '〘', '〚', '(', '[', '{']
33 call setline('.', '这是个测试'.punct.'试试 CJK 行禁则补丁。')
34 normal gqq
35 call assert_equal('这是个测试', getline(1))
36 %d_
37 endfor
38endfunc
39
40func Test_cjk_linebreak_before()
41 set formatoptions=croqn2mB1j
42 call Run_cjk_linebreak_before()
43endfunc
44
45func Test_cjk_linebreak_before_rigorous()
46 set formatoptions=croqn2mB1j]
47 call Run_cjk_linebreak_before()
48endfunc
49
50func Run_cjk_linebreak_nobetween()
51 " …… must not start a line
52 call setline('.', '这是个测试……试试 CJK 行禁则补丁。')
53 set textwidth=12 ambiwidth=double
54 normal gqq
55 " TODO: this fails
56 " call assert_equal('这是个测试……', getline(1))
57 %d_
58
59 call setline('.', '这是一个测试……试试 CJK 行禁则补丁。')
60 set textwidth=12 ambiwidth=double
61 normal gqq
62 call assert_equal('这是一个测', getline(1))
63 %d_
64
65 " but —— can
66 call setline('.', '这是个测试——试试 CJK 行禁则补丁。')
67 set textwidth=12 ambiwidth=double
68 normal gqq
69 call assert_equal('这是个测试', getline(1))
70endfunc
71
72func Test_cjk_linebreak_nobetween()
73 set formatoptions=croqn2mB1j
74 call Run_cjk_linebreak_nobetween()
75endfunc
76
77func Test_cjk_linebreak_nobetween_rigorous()
78 set formatoptions=croqn2mB1j]
79 call Run_cjk_linebreak_nobetween()
80endfunc
81
82func Test_cjk_linebreak_join_punct()
83 for punct in ['——', '〗', ',', '。', '……']
84 call setline(1, '文本文本'.punct)
85 call setline(2, 'English')
86 set formatoptions=croqn2mB1j
87 normal ggJ
88 call assert_equal('文本文本'.punct.'English', getline(1))
89 %d_
90 endfor
91endfunc