Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore user's original cursor settings on exit #6

Merged
merged 1 commit into from
Apr 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions autoload/leaderf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ function! leaderf#LfPy(cmd)
if v:version > 703
exec g:Lf_py . a:cmd
else
let old_gcr = &gcr
let old_t_ve = &t_ve
try
exec g:Lf_py . a:cmd
catch /^Vim:Interrupt$/ " catch interrupts (CTRL-C)
set gcr&
set t_ve&
let &gcr = old_gcr
let &t_ve = old_t_ve
let obj = substitute(a:cmd,'\..*', '', '')
exec g:Lf_py . obj .".quit()"
call getchar(0)
Expand Down
10 changes: 6 additions & 4 deletions autoload/leaderf/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@
def ctrlCursor(func):
@wraps(func)
def deco(*args, **kwargs):
vim.command("let g:lf_old_gcr = &gcr")
vim.command("let g:lf_old_t_ve = &t_ve")
vim.command("set gcr=a:invisible")
vim.command("set t_ve=")
try:
for i in func(*args, **kwargs):
yield i
finally:
try:
vim.command("set gcr&")
vim.command("set t_ve&")
vim.command("let &gcr = g:lf_old_gcr")
vim.command("let &t_ve = g:lf_old_t_ve")
except: #due to vim's bug, I have to do like this
try:
vim.command("set gcr&")
vim.command("set t_ve&")
vim.command("let &gcr = g:lf_old_gcr")
vim.command("let &t_ve = g:lf_old_t_ve")
except:
pass
return deco
Expand Down