File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,18 @@ fun! pymode#run#Run(line1, line2) "{{{
17
17
try
18
18
py context = globals ()
19
19
py context[' raw_input' ] = context[' input' ] = lambda s: vim .eval (' input("{0}")' .format (s ))
20
- py execfile (vim .eval (' expand("%:p")' ), context)
20
+ python << ENDPYTHON
21
+ try :
22
+ execfile (vim .eval (' expand("%:p")' ), context)
23
+ # Vim cannot handle a SystemExit error raised by Python, so we need to trap it here, and
24
+ # handle it specially
25
+ except SystemExit as e :
26
+ if e .code:
27
+ # A non- false code indicates abnormal termination. A false code will be treated as a
28
+ # successful run, and the error will be hidden from Vim
29
+ vim .command (' echohl Error | echo "Script exited with code {0}" | echohl none' .format (e .code))
30
+ vim .command (' return' )
31
+ ENDPYTHON
21
32
py out, err = sys.stdout.getvalue ().strip (), sys.stderr.getvalue ()
22
33
py sys.stdout, sys.stderr = stdout_, stderr_
23
34
38
49
EOF
39
50
40
51
catch /.*/
41
-
52
+
42
53
echohl Error | echo " Run-time error." | echohl none
43
54
44
55
endtry
You can’t perform that action at this time.
0 commit comments