Mercurial > vim
comparison src/testdir/test_terminal.vim @ 12009:0d9bfdb3f6f7 v8.0.0885
patch 8.0.0885: terminal window scrollback is stored inefficiently
commit https://github.com/vim/vim/commit/33a43bee9cdc62f9cd0999eb23c6eca01b4d2d67
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 6 21:36:22 2017 +0200
patch 8.0.0885: terminal window scrollback is stored inefficiently
Problem: Terminal window scrollback is stored inefficiently.
Solution: Store the text in the Vim buffer.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 06 Aug 2017 21:45:03 +0200 |
parents | 5cc005cf312f |
children | 1f4e7361ce89 |
comparison
equal
deleted
inserted
replaced
12008:41ab44ba9753 | 12009:0d9bfdb3f6f7 |
---|---|
95 exe g:buf . 'bwipe!' | 95 exe g:buf . 'bwipe!' |
96 let g:buf = 0 | 96 let g:buf = 0 |
97 endfunc | 97 endfunc |
98 | 98 |
99 func Test_terminal_nasty_cb() | 99 func Test_terminal_nasty_cb() |
100 let cmd = Get_cat_cmd() | 100 let cmd = Get_cat_123_cmd() |
101 let g:buf = term_start(cmd, {'exit_cb': function('s:Nasty_exit_cb')}) | 101 let g:buf = term_start(cmd, {'exit_cb': function('s:Nasty_exit_cb')}) |
102 let g:job = term_getjob(g:buf) | 102 let g:job = term_getjob(g:buf) |
103 | 103 |
104 call WaitFor('job_status(g:job) == "dead"') | 104 call WaitFor('job_status(g:job) == "dead"') |
105 call WaitFor('g:buf == 0') | 105 call WaitFor('g:buf == 0') |
133 call assert_equal('', l) | 133 call assert_equal('', l) |
134 let l = term_getline(a:buf, 1) | 134 let l = term_getline(a:buf, 1) |
135 call assert_equal('123', l) | 135 call assert_equal('123', l) |
136 endfunc | 136 endfunc |
137 | 137 |
138 func Get_cat_cmd() | 138 func Get_cat_123_cmd() |
139 if has('win32') | 139 if has('win32') |
140 return 'cmd /c "cls && color 2 && echo 123"' | 140 return 'cmd /c "cls && color 2 && echo 123"' |
141 else | 141 else |
142 call writefile(["\<Esc>[32m123"], 'Xtext') | 142 call writefile(["\<Esc>[32m123"], 'Xtext') |
143 return "cat Xtext" | 143 return "cat Xtext" |
144 endif | 144 endif |
145 endfunc | 145 endfunc |
146 | 146 |
147 func Test_terminal_scrape() | 147 func Test_terminal_scrape_123() |
148 let cmd = Get_cat_cmd() | 148 let cmd = Get_cat_123_cmd() |
149 let buf = term_start(cmd) | 149 let buf = term_start(cmd) |
150 | 150 |
151 let termlist = term_list() | 151 let termlist = term_list() |
152 call assert_equal(1, len(termlist)) | 152 call assert_equal(1, len(termlist)) |
153 call assert_equal(buf, termlist[0]) | 153 call assert_equal(buf, termlist[0]) |
170 | 170 |
171 exe buf . 'bwipe' | 171 exe buf . 'bwipe' |
172 call delete('Xtext') | 172 call delete('Xtext') |
173 endfunc | 173 endfunc |
174 | 174 |
175 func Test_terminal_scrape_multibyte() | |
176 if !has('multi_byte') | |
177 return | |
178 endif | |
179 call writefile(["léttまrs"], 'Xtext') | |
180 if has('win32') | |
181 let cmd = 'cmd /c "type Xtext"' | |
182 else | |
183 let cmd = "cat Xtext" | |
184 endif | |
185 let buf = term_start(cmd) | |
186 | |
187 call term_wait(buf) | |
188 if has('win32') | |
189 " TODO: this should not be needed | |
190 sleep 100m | |
191 endif | |
192 | |
193 let l = term_scrape(buf, 1) | |
194 call assert_true(len(l) >= 7) | |
195 call assert_equal('l', l[0].chars) | |
196 call assert_equal('é', l[1].chars) | |
197 call assert_equal(1, l[1].width) | |
198 call assert_equal('t', l[2].chars) | |
199 call assert_equal('t', l[3].chars) | |
200 call assert_equal('ま', l[4].chars) | |
201 call assert_equal(2, l[4].width) | |
202 call assert_equal('r', l[5].chars) | |
203 call assert_equal('s', l[6].chars) | |
204 | |
205 let g:job = term_getjob(buf) | |
206 call WaitFor('job_status(g:job) == "dead"') | |
207 call term_wait(buf) | |
208 | |
209 exe buf . 'bwipe' | |
210 call delete('Xtext') | |
211 endfunc | |
212 | |
175 func Test_terminal_size() | 213 func Test_terminal_size() |
176 let cmd = Get_cat_cmd() | 214 let cmd = Get_cat_123_cmd() |
177 | 215 |
178 exe '5terminal ' . cmd | 216 exe '5terminal ' . cmd |
179 let size = term_getsize('') | 217 let size = term_getsize('') |
180 bwipe! | 218 bwipe! |
181 call assert_equal(5, size[0]) | 219 call assert_equal(5, size[0]) |