From 5bea57ebf5ef1ef0b5ebf2e6cc6062bf94cd87f2 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 28 Apr 2014 12:29:33 +0900 Subject: [PATCH] Retain cursor position on close (#27) This however doesn't work if Goyo window is closed with `:q` --- plugin/goyo.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/goyo.vim b/plugin/goyo.vim index 3814872..4265e14 100644 --- a/plugin/goyo.vim +++ b/plugin/goyo.vim @@ -244,6 +244,8 @@ function! s:goyo_off() let goyo_disabled_airline = t:goyo_disabled_airline let goyo_disabled_powerline = t:goyo_disabled_powerline let goyo_disabled_lightline = t:goyo_disabled_lightline + let goyo_orig_buffer = t:goyo_master + let [line, col] = [line('.'), col('.')] if tabpagenr() == 1 tabnew @@ -252,6 +254,9 @@ function! s:goyo_off() endif tabclose execute 'normal! '.s:orig_tab.'gt' + if winbufnr(0) == goyo_orig_buffer + execute printf('normal! %dG%d|', line, col) + endif let wmh = remove(goyo_revert, 'winminheight') let wh = remove(goyo_revert, 'winheight')