From 576bd64482df3caafadb5852c985421fb0dc32ae Mon Sep 17 00:00:00 2001 From: Jaehwang Jerry Jung Date: Sun, 1 Aug 2021 00:43:34 +0900 Subject: [PATCH] =?UTF-8?q?{Save,Restore}ScreenState=20=E2=86=92=20win{sav?= =?UTF-8?q?e,rest}view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/nerdcommenter.vim | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/autoload/nerdcommenter.vim b/autoload/nerdcommenter.vim index 40475fb..b022a9e 100644 --- a/autoload/nerdcommenter.vim +++ b/autoload/nerdcommenter.vim @@ -1259,9 +1259,9 @@ function! nerdcommenter#Comment(mode, type) range abort endtry elseif a:type ==? 'ToEOL' - call s:SaveScreenState() + let view = winsaveview() call s:CommentBlock(firstLine, firstLine, col('.'), col('$')-1, 1) - call s:RestoreScreenState() + call winrestview(view) elseif a:type ==? 'Append' call s:AppendCommentToLine() @@ -2907,21 +2907,6 @@ function! s:ReplaceRightMostDelim(toReplace, replacor, str) abort return line endfunction -"FUNCTION: s:RestoreScreenState() -" -"Sets the screen state back to what it was when s:SaveScreenState was last -"called. -" -function! s:RestoreScreenState() abort - if !exists('t:NERDComOldTopLine') || !exists('t:NERDComOldPos') - throw 'NERDCommenter exception: cannot restore screen' - endif - - call cursor(t:NERDComOldTopLine, 0) - normal! zt - call setpos('.', t:NERDComOldPos) -endfunction - " Function: s:Right(...) " returns right delimiter data function! s:Right(...) abort @@ -2983,14 +2968,6 @@ function! s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottoml return rightMostIndx endfunction -"FUNCTION: s:SaveScreenState() -"Saves the current cursor position in the current buffer and the window -"scroll position -function! s:SaveScreenState() abort - let t:NERDComOldPos = getpos('.') - let t:NERDComOldTopLine = line('w0') -endfunction - " Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line) " This function takes a line and swaps the outer most multi-part delimiters for " place holders