Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 1 | " Tests for 'conceal'. |
| 2 | " Also see test88.in (should be converted to a test function here). |
| 3 | |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 4 | source check.vim |
| 5 | CheckFeature conceal |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 6 | |
| 7 | source screendump.vim |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 8 | CheckScreendump |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 9 | |
| 10 | func Test_conceal_two_windows() |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 11 | let code =<< trim [CODE] |
| 12 | let lines = ["one one one one one", "two |hidden| here", "three |hidden| three"] |
| 13 | call setline(1, lines) |
| 14 | syntax match test /|hidden|/ conceal |
| 15 | set conceallevel=2 |
| 16 | set concealcursor= |
| 17 | exe "normal /here\r" |
| 18 | new |
| 19 | call setline(1, lines) |
| 20 | call setline(4, "Second window") |
| 21 | syntax match test /|hidden|/ conceal |
| 22 | set conceallevel=2 |
| 23 | set concealcursor=nc |
| 24 | exe "normal /here\r" |
| 25 | [CODE] |
| 26 | |
| 27 | call writefile(code, 'XTest_conceal') |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 28 | " Check that cursor line is concealed |
| 29 | let buf = RunVimInTerminal('-S XTest_conceal', {}) |
| 30 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_01', {}) |
| 31 | |
| 32 | " Check that with concealed text vertical cursor movement is correct. |
| 33 | call term_sendkeys(buf, "k") |
| 34 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_02', {}) |
| 35 | |
| 36 | " Check that with cursor line is not concealed |
| 37 | call term_sendkeys(buf, "j") |
| 38 | call term_sendkeys(buf, ":set concealcursor=\r") |
| 39 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_03', {}) |
| 40 | |
| 41 | " Check that with cursor line is not concealed when moving cursor down |
| 42 | call term_sendkeys(buf, "j") |
| 43 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_04', {}) |
| 44 | |
| 45 | " Check that with cursor line is not concealed when switching windows |
| 46 | call term_sendkeys(buf, "\<C-W>\<C-W>") |
| 47 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_05', {}) |
| 48 | |
| 49 | " Check that with cursor line is only concealed in Normal mode |
| 50 | call term_sendkeys(buf, ":set concealcursor=n\r") |
| 51 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_06n', {}) |
| 52 | call term_sendkeys(buf, "a") |
| 53 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_06i', {}) |
| 54 | call term_sendkeys(buf, "\<Esc>/e") |
| 55 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_06c', {}) |
| 56 | call term_sendkeys(buf, "\<Esc>v") |
| 57 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_06v', {}) |
| 58 | call term_sendkeys(buf, "\<Esc>") |
| 59 | |
| 60 | " Check that with cursor line is only concealed in Insert mode |
| 61 | call term_sendkeys(buf, ":set concealcursor=i\r") |
| 62 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_07n', {}) |
| 63 | call term_sendkeys(buf, "a") |
| 64 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_07i', {}) |
| 65 | call term_sendkeys(buf, "\<Esc>/e") |
| 66 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_07c', {}) |
| 67 | call term_sendkeys(buf, "\<Esc>v") |
| 68 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_07v', {}) |
| 69 | call term_sendkeys(buf, "\<Esc>") |
| 70 | |
| 71 | " Check that with cursor line is only concealed in Command mode |
| 72 | call term_sendkeys(buf, ":set concealcursor=c\r") |
| 73 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_08n', {}) |
| 74 | call term_sendkeys(buf, "a") |
| 75 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_08i', {}) |
| 76 | call term_sendkeys(buf, "\<Esc>/e") |
| 77 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_08c', {}) |
| 78 | call term_sendkeys(buf, "\<Esc>v") |
| 79 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_08v', {}) |
| 80 | call term_sendkeys(buf, "\<Esc>") |
| 81 | |
| 82 | " Check that with cursor line is only concealed in Visual mode |
| 83 | call term_sendkeys(buf, ":set concealcursor=v\r") |
| 84 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_09n', {}) |
| 85 | call term_sendkeys(buf, "a") |
| 86 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_09i', {}) |
| 87 | call term_sendkeys(buf, "\<Esc>/e") |
| 88 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_09c', {}) |
| 89 | call term_sendkeys(buf, "\<Esc>v") |
| 90 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_09v', {}) |
| 91 | call term_sendkeys(buf, "\<Esc>") |
| 92 | |
Bram Moolenaar | 465e8b5 | 2019-01-11 20:42:28 +0100 | [diff] [blame] | 93 | " Check moving the cursor while in insert mode. |
| 94 | call term_sendkeys(buf, ":set concealcursor=\r") |
| 95 | call term_sendkeys(buf, "a") |
| 96 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_10', {}) |
| 97 | call term_sendkeys(buf, "\<Down>") |
| 98 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_11', {}) |
| 99 | call term_sendkeys(buf, "\<Esc>") |
| 100 | |
| 101 | " Check the "o" command |
| 102 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_12', {}) |
| 103 | call term_sendkeys(buf, "o") |
| 104 | call VerifyScreenDump(buf, 'Test_conceal_two_windows_13', {}) |
| 105 | call term_sendkeys(buf, "\<Esc>") |
| 106 | |
Bram Moolenaar | 429ab17 | 2019-01-11 15:54:45 +0100 | [diff] [blame] | 107 | " clean up |
| 108 | call StopVimInTerminal(buf) |
| 109 | call delete('XTest_conceal') |
| 110 | endfunc |
Bram Moolenaar | bbee8d5 | 2019-01-14 21:51:40 +0100 | [diff] [blame] | 111 | |
| 112 | func Test_conceal_with_cursorline() |
| 113 | " Opens a help window, where 'conceal' is set, switches to the other window |
| 114 | " where 'cursorline' needs to be updated when the cursor moves. |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 115 | let code =<< trim [CODE] |
| 116 | set cursorline |
| 117 | normal othis is a test |
| 118 | new |
| 119 | call setline(1, ["one", "two", "three", "four", "five"]) |
| 120 | set ft=help |
| 121 | normal M |
| 122 | [CODE] |
| 123 | |
| 124 | call writefile(code, 'XTest_conceal_cul') |
Bram Moolenaar | bbee8d5 | 2019-01-14 21:51:40 +0100 | [diff] [blame] | 125 | let buf = RunVimInTerminal('-S XTest_conceal_cul', {}) |
| 126 | call VerifyScreenDump(buf, 'Test_conceal_cul_01', {}) |
| 127 | |
| 128 | call term_sendkeys(buf, ":wincmd w\r") |
| 129 | call VerifyScreenDump(buf, 'Test_conceal_cul_02', {}) |
| 130 | |
| 131 | call term_sendkeys(buf, "k") |
| 132 | call VerifyScreenDump(buf, 'Test_conceal_cul_03', {}) |
| 133 | |
| 134 | " clean up |
| 135 | call StopVimInTerminal(buf) |
| 136 | call delete('XTest_conceal_cul') |
| 137 | endfunc |
Bram Moolenaar | 5babc6e | 2019-09-14 21:55:51 +0200 | [diff] [blame] | 138 | |
| 139 | func Test_conceal_resize_term() |
| 140 | let code =<< trim [CODE] |
| 141 | call setline(1, '`one` `two` `three` `four` `five`, the backticks should be concealed') |
| 142 | setl cocu=n cole=3 |
| 143 | syn region CommentCodeSpan matchgroup=Comment start=/`/ end=/`/ concealends |
| 144 | normal fb |
| 145 | [CODE] |
| 146 | call writefile(code, 'XTest_conceal_resize') |
| 147 | let buf = RunVimInTerminal('-S XTest_conceal_resize', {'rows': 6}) |
| 148 | call VerifyScreenDump(buf, 'Test_conceal_resize_01', {}) |
| 149 | |
| 150 | call win_execute(buf->win_findbuf()[0], 'wincmd +') |
| 151 | call term_wait(buf) |
| 152 | call VerifyScreenDump(buf, 'Test_conceal_resize_02', {}) |
| 153 | |
| 154 | " clean up |
| 155 | call StopVimInTerminal(buf) |
| 156 | call delete('XTest_conceal_resize') |
| 157 | endfunc |