annotate src/testdir/shared.vim @ 12763:7f27e9769f62 v8.0.1259

patch 8.0.1259: search test can be flaky commit https://github.com/vim/vim/commit/13deab8d08145c1f6e2a3e82cb547bc7f87a3686 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 4 18:48:43 2017 +0100 patch 8.0.1259: search test can be flaky Problem: Search test can be flaky. Solution: Use WaitFor() instead of a delay. Make it possible to pass a funcref to WaitFor() to avoid the need for global variables. (James McCoy, closes #2282)
author Christian Brabandt <cb@256bit.org>
date Sat, 04 Nov 2017 19:00:05 +0100
parents af961e38e508
children 013c44d9dc09
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Functions shared by several tests.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
3 " Only load this script once.
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
4 if exists('*WaitFor')
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
5 finish
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
6 endif
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
7
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 " Get the name of the Python executable.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 " Also keeps it in s:python.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 func PythonProg()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 " This test requires the Python command to run the test server.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " This most likely only works on Unix and Windows.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 if has('unix')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 " We also need the job feature or the pkill command to make sure the server
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 " can be stopped.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 if !(executable('python') && (has('job') || executable('pkill')))
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 return ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 let s:python = 'python'
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 elseif has('win32')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 " Use Python Launcher for Windows (py.exe) if available.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 if executable('py.exe')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 let s:python = 'py.exe'
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 elseif executable('python.exe')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 let s:python = 'python.exe'
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 return ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 return ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 return s:python
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 " Run "cmd". Returns the job if using a job.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 func RunCommand(cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 let job = 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 if has('job')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 let job = job_start(a:cmd, {"stoponexit": "hup"})
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call job_setoptions(job, {"stoponexit": "kill"})
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 elseif has('win32')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 exe 'silent !start cmd /c start "test_channel" ' . a:cmd
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 exe 'silent !' . a:cmd . '&'
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 return job
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 " Read the port number from the Xportnr file.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 func GetPort()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 let l = []
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 for i in range(200)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 try
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 let l = readfile("Xportnr")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 catch
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 endtry
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 if len(l) >= 1
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 break
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 sleep 10m
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 endfor
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call delete("Xportnr")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 if len(l) == 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 " Can't make the connection, give up.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 return 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 return l[0]
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 " Run a Python server for "cmd" and call "testfunc".
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 " Always kills the server before returning.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 func RunServer(cmd, testfunc, args)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 " The Python program writes the port number in Xportnr.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 call delete("Xportnr")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 if len(a:args) == 1
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 let arg = ' ' . a:args[0]
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 let arg = ''
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 let pycmd = s:python . " " . a:cmd . arg
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 try
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 let g:currentJob = RunCommand(pycmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 " Wait for up to 2 seconds for the port number to be there.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 let port = GetPort()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 if port == 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 call assert_false(1, "Can't start " . a:cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 return
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 call call(function(a:testfunc), [port])
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 catch
10422
e664ee056a84 commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents: 10309
diff changeset
96 call assert_false(1, 'Caught exception: "' . v:exception . '" in ' . v:throwpoint)
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 finally
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 call s:kill_server(a:cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 endtry
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 func s:kill_server(cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 if has('job')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 if exists('g:currentJob')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 call job_stop(g:currentJob)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 unlet g:currentJob
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 elseif has('win32')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 let cmd = substitute(a:cmd, ".py", '', '')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 call system('taskkill /IM ' . s:python . ' /T /F /FI "WINDOWTITLE eq ' . cmd . '"')
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 else
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 call system("pkill -f " . a:cmd)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 endif
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 endfunc
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115
12763
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
116 " Wait for up to a second for "expr" to become true. "expr" can be a
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
117 " stringified expression to evaluate, or a funcref without arguments.
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
118 "
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
119 " Return time slept in milliseconds. With the +reltime feature this can be
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
120 " more than the actual waiting time. Without +reltime it can also be less.
11709
c3227699ad4d patch 8.0.0737: crash when X11 selection is very big
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
121 func WaitFor(expr, ...)
c3227699ad4d patch 8.0.0737: crash when X11 selection is very big
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
122 let timeout = get(a:000, 0, 1000)
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
123 " using reltime() is more accurate, but not always available
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
124 if has('reltime')
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
125 let start = reltime()
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
126 else
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
127 let slept = 0
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
128 endif
12763
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
129 if type(a:expr) == v:t_func
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
130 let Test = a:expr
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
131 else
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
132 let Test = {-> eval(a:expr) }
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
133 endif
11709
c3227699ad4d patch 8.0.0737: crash when X11 selection is very big
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
134 for i in range(timeout / 10)
12763
7f27e9769f62 patch 8.0.1259: search test can be flaky
Christian Brabandt <cb@256bit.org>
parents: 12742
diff changeset
135 if Test()
12742
af961e38e508 patch 8.0.1249: no error when WaitFor() gets an invalid wrong expression
Christian Brabandt <cb@256bit.org>
parents: 12734
diff changeset
136 if has('reltime')
af961e38e508 patch 8.0.1249: no error when WaitFor() gets an invalid wrong expression
Christian Brabandt <cb@256bit.org>
parents: 12734
diff changeset
137 return float2nr(reltimefloat(reltime(start)) * 1000)
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 endif
12742
af961e38e508 patch 8.0.1249: no error when WaitFor() gets an invalid wrong expression
Christian Brabandt <cb@256bit.org>
parents: 12734
diff changeset
139 return slept
af961e38e508 patch 8.0.1249: no error when WaitFor() gets an invalid wrong expression
Christian Brabandt <cb@256bit.org>
parents: 12734
diff changeset
140 endif
9933
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
141 if !has('reltime')
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
142 let slept += 10
7f38e72a9d65 commit https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Christian Brabandt <cb@256bit.org>
parents: 9818
diff changeset
143 endif
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 sleep 10m
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 endfor
12734
810a4c3d4f7e patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents: 12602
diff changeset
146 throw 'WaitFor() timed out after ' . timeout . ' msec'
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 endfunc
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
148
10309
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
149 " Wait for up to a given milliseconds.
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
150 " With the +timers feature this waits for key-input by getchar(), Resume()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
151 " feeds key-input and resumes process. Return time waited in milliseconds.
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
152 " Without +timers it uses simply :sleep.
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
153 func Standby(msec)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
154 if has('timers')
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
155 let start = reltime()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
156 let g:_standby_timer = timer_start(a:msec, function('s:feedkeys'))
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
157 call getchar()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
158 return float2nr(reltimefloat(reltime(start)) * 1000)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
159 else
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
160 execute 'sleep ' a:msec . 'm'
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
161 return a:msec
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
162 endif
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
163 endfunc
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
164
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
165 func Resume()
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
166 if exists('g:_standby_timer')
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
167 call timer_stop(g:_standby_timer)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
168 call s:feedkeys(0)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
169 unlet g:_standby_timer
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
170 endif
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
171 endfunc
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
172
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
173 func s:feedkeys(timer)
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
174 call feedkeys('x', 'nt')
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
175 endfunc
88331ee68367 commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents: 9933
diff changeset
176
12602
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
177 " Get $VIMPROG to run Vim executable.
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
178 " The Makefile writes it as the first line in the "vimcmd" file.
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
179 func GetVimProg()
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
180 if !filereadable('vimcmd')
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
181 return ''
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
182 endif
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
183 return readfile('vimcmd')[0]
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
184 endfunc
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
185
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
186 " Get the command to run Vim, with -u NONE and --not-a-term arguments.
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
187 " If there is an argument use it instead of "NONE".
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
188 " Returns an empty string on error.
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
189 func GetVimCommand(...)
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
190 if !filereadable('vimcmd')
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
191 return ''
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
192 endif
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
193 if a:0 == 0
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
194 let name = 'NONE'
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
195 else
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
196 let name = a:1
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
197 endif
12602
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
198 " For Unix Makefile writes the command to use in the second line of the
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
199 " "vimcmd" file, including environment options.
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
200 " Other Makefiles just write the executable in the first line, so fall back
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
201 " to that if there is no second line.
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
202 let lines = readfile('vimcmd')
9359ed49d375 patch 8.0.1179: Test_popup_and_window_resize() does not always pass
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
203 let cmd = get(lines, 1, lines[0])
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
204 let cmd = substitute(cmd, '-u \f\+', '-u ' . name, '')
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
205 if cmd !~ '-u '. name
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12106
diff changeset
206 let cmd = cmd . ' -u ' . name
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
207 endif
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
208 let cmd .= ' --not-a-term'
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
209 let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '')
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
210 return cmd
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
211 endfunc
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
212
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
213 " Run Vim, using the "vimcmd" file and "-u NORC".
9806
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
214 " "before" is a list of Vim commands to be executed before loading plugins.
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
215 " "after" is a list of Vim commands to be executed after loading plugins.
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
216 " Plugins are not loaded, unless 'loadplugins' is set in "before".
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
217 " Return 1 if Vim could be executed.
9794
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
218 func RunVim(before, after, arguments)
9818
5c288e5e1493 commit https://github.com/vim/vim/commit/7a9a5f4019ce332cb11ce5370e3fa609299ce737
Christian Brabandt <cb@256bit.org>
parents: 9810
diff changeset
219 return RunVimPiped(a:before, a:after, a:arguments, '')
9806
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
220 endfunc
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
221
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
222 func RunVimPiped(before, after, arguments, pipecmd)
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
223 let cmd = GetVimCommand()
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents: 11022
diff changeset
224 if cmd == ''
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
225 return 0
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
226 endif
9804
4ef933b816e7 commit https://github.com/vim/vim/commit/ba98bef1910094179bf90b9467b6e2d2f9462601
Christian Brabandt <cb@256bit.org>
parents: 9794
diff changeset
227 let args = ''
9794
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
228 if len(a:before) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
229 call writefile(a:before, 'Xbefore.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
230 let args .= ' --cmd "so Xbefore.vim"'
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
231 endif
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
232 if len(a:after) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
233 call writefile(a:after, 'Xafter.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
234 let args .= ' -S Xafter.vim'
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
235 endif
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
236
9806
108b62925cb0 commit https://github.com/vim/vim/commit/3a938383396d4ab352bbb4d806938302debdae2c
Christian Brabandt <cb@256bit.org>
parents: 9804
diff changeset
237 exe "silent !" . a:pipecmd . cmd . args . ' ' . a:arguments
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
238
9794
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
239 if len(a:before) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
240 call delete('Xbefore.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
241 endif
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
242 if len(a:after) > 0
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
243 call delete('Xafter.vim')
fd32f719d34f commit https://github.com/vim/vim/commit/472a0a880a709c027f4b19cfa56c08e78818112d
Christian Brabandt <cb@256bit.org>
parents: 9788
diff changeset
244 endif
9778
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
245 return 1
4360b2b46125 commit https://github.com/vim/vim/commit/66459b7c98c67f8a9d39de8f08e8e8f1fca0e359
Christian Brabandt <cb@256bit.org>
parents: 9517
diff changeset
246 endfunc
12106
d2c20ec4b95a patch 8.0.0933: terminal test tries to start GUI when it's not possible
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
247
d2c20ec4b95a patch 8.0.0933: terminal test tries to start GUI when it's not possible
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
248 func CanRunGui()
d2c20ec4b95a patch 8.0.0933: terminal test tries to start GUI when it's not possible
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
249 return has('gui') && ($DISPLAY != "" || has('gui_running'))
d2c20ec4b95a patch 8.0.0933: terminal test tries to start GUI when it's not possible
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
250 endfunc