Skip to content

Commit e6ee9ee

Browse files
committed
stay in vim-ipython shell if executing from it
1 parent 2ec9130 commit e6ee9ee

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ftplugin/python/ipy.vim

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ def update_subchannel_msgs(debug=False):
170170
db = vim.current.buffer
171171
else:
172172
db = []
173-
vim.command("pcl")
174-
vim.command("silent pedit vim-ipython")
175-
vim.command("normal P") #switch to preview window
173+
startedin_vimipython = vim.current.buffer.name.endswith('vim-ipython')
174+
if not startedin_vimipython:
175+
vim.command("pcl")
176+
vim.command("silent pedit vim-ipython")
177+
vim.command("normal P") #switch to preview window
176178
# subchannel window quick quit key 'q'
177179
vim.command('map <buffer> q :q<CR>')
178180
vim.command("set bufhidden=hide buftype=nofile ft=python")
@@ -219,7 +221,8 @@ def update_subchannel_msgs(debug=False):
219221
except:
220222
b.append([l.encode(vim_encoding) for l in s.splitlines()])
221223
vim.command('normal G') # go to the end of the file
222-
vim.command('silent e #|silent pedit vim-ipython')
224+
if not startedin_vimipython:
225+
vim.command('normal p') # go back to where you were
223226

224227
def get_child_msg(msg_id):
225228
# XXX: message handling should be split into its own process in the future
@@ -254,7 +257,6 @@ def with_subchannel(f):
254257
f()
255258
if monitor_subchannel:
256259
update_subchannel_msgs()
257-
vim.command('normal p') # go back to where you were
258260
except AttributeError: #if km is None
259261
echo("not connected to IPython", 'Error')
260262
return f_with_update

0 commit comments

Comments
 (0)