Mercurial > vim
comparison src/testdir/shared.vim @ 11709:c3227699ad4d v8.0.0737
patch 8.0.0737: crash when X11 selection is very big
commit https://github.com/vim/vim/commit/cdb7e1b7f9e18a7b165ff09103a9994f84966123
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jul 19 19:55:58 2017 +0200
patch 8.0.0737: crash when X11 selection is very big
Problem: Crash when X11 selection is very big.
Solution: Use static items instead of allocating them. Add callbacks.
(Ozaki Kiichi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 19 Jul 2017 20:00:03 +0200 |
parents | 9836b701afd9 |
children | d2c20ec4b95a |
comparison
equal
deleted
inserted
replaced
11708:1bb52ba993d9 | 11709:c3227699ad4d |
---|---|
109 endfunc | 109 endfunc |
110 | 110 |
111 " Wait for up to a second for "expr" to become true. | 111 " Wait for up to a second for "expr" to become true. |
112 " Return time slept in milliseconds. With the +reltime feature this can be | 112 " Return time slept in milliseconds. With the +reltime feature this can be |
113 " more than the actual waiting time. Without +reltime it can also be less. | 113 " more than the actual waiting time. Without +reltime it can also be less. |
114 func WaitFor(expr) | 114 func WaitFor(expr, ...) |
115 let timeout = get(a:000, 0, 1000) | |
115 " using reltime() is more accurate, but not always available | 116 " using reltime() is more accurate, but not always available |
116 if has('reltime') | 117 if has('reltime') |
117 let start = reltime() | 118 let start = reltime() |
118 else | 119 else |
119 let slept = 0 | 120 let slept = 0 |
120 endif | 121 endif |
121 for i in range(100) | 122 for i in range(timeout / 10) |
122 try | 123 try |
123 if eval(a:expr) | 124 if eval(a:expr) |
124 if has('reltime') | 125 if has('reltime') |
125 return float2nr(reltimefloat(reltime(start)) * 1000) | 126 return float2nr(reltimefloat(reltime(start)) * 1000) |
126 endif | 127 endif |
131 if !has('reltime') | 132 if !has('reltime') |
132 let slept += 10 | 133 let slept += 10 |
133 endif | 134 endif |
134 sleep 10m | 135 sleep 10m |
135 endfor | 136 endfor |
136 return 1000 | 137 return timeout |
137 endfunc | 138 endfunc |
138 | 139 |
139 " Wait for up to a given milliseconds. | 140 " Wait for up to a given milliseconds. |
140 " With the +timers feature this waits for key-input by getchar(), Resume() | 141 " With the +timers feature this waits for key-input by getchar(), Resume() |
141 " feeds key-input and resumes process. Return time waited in milliseconds. | 142 " feeds key-input and resumes process. Return time waited in milliseconds. |