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) "{{{
1717 try
1818 py context = globals ()
1919 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
2132 py out, err = sys.stdout.getvalue ().strip (), sys.stderr.getvalue ()
2233 py sys.stdout, sys.stderr = stdout_, stderr_
2334
3849EOF
3950
4051 catch /.*/
41-
52+
4253 echohl Error | echo " Run-time error." | echohl none
4354
4455 endtry
You can’t perform that action at this time.
0 commit comments