Skip to content

Commit 9655d4b

Browse files
committed
remember vim-ipython shell size (closes #16)
also update the preview height on every update, to remember the height even after closing the 'vim-ipython' shell
1 parent f8b8f2a commit 9655d4b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

ftplugin/python/ipy.vim

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,22 @@ def update_subchannel_msgs(debug=False):
200200
b = vim.current.buffer
201201
startedin_vimipython = (b.name is not None and b.name.endswith('vim-ipython'))
202202
if not startedin_vimipython:
203-
vim.command("pcl")
204-
vim.command("silent pedit vim-ipython")
203+
# switch to preview window
204+
vim.command(
205+
"try"
206+
"|silent! wincmd P"
207+
"|catch /^Vim\%((\a\+)\)\=:E441/"
208+
"|silent pedit vim-ipython"
209+
"|silent! wincmd P"
210+
"|endtry")
211+
# if the current window is called 'vim-ipython'
212+
if vim.eval('@%')=='vim-ipython':
213+
# set the preview window height to the current height
214+
vim.command("set pvh=" + vim.eval('winheight(0)'))
215+
else:
216+
# close preview window, it was something other than 'vim-ipython'
217+
vim.command("pcl")
218+
vim.command("silent pedit vim-ipython")
205219
vim.command("normal P") #switch to preview window
206220
# subchannel window quick quit key 'q'
207221
vim.command('map <buffer> q :q<CR>')

0 commit comments

Comments
 (0)