mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-10 02:33:48 -05:00
{Save,Restore}ScreenState → win{save,rest}view
This commit is contained in:
@@ -1259,9 +1259,9 @@ function! nerdcommenter#Comment(mode, type) range abort
|
|||||||
endtry
|
endtry
|
||||||
|
|
||||||
elseif a:type ==? 'ToEOL'
|
elseif a:type ==? 'ToEOL'
|
||||||
call s:SaveScreenState()
|
let view = winsaveview()
|
||||||
call s:CommentBlock(firstLine, firstLine, col('.'), col('$')-1, 1)
|
call s:CommentBlock(firstLine, firstLine, col('.'), col('$')-1, 1)
|
||||||
call s:RestoreScreenState()
|
call winrestview(view)
|
||||||
|
|
||||||
elseif a:type ==? 'Append'
|
elseif a:type ==? 'Append'
|
||||||
call s:AppendCommentToLine()
|
call s:AppendCommentToLine()
|
||||||
@@ -2907,21 +2907,6 @@ function! s:ReplaceRightMostDelim(toReplace, replacor, str) abort
|
|||||||
return line
|
return line
|
||||||
endfunction
|
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(...)
|
" Function: s:Right(...)
|
||||||
" returns right delimiter data
|
" returns right delimiter data
|
||||||
function! s:Right(...) abort
|
function! s:Right(...) abort
|
||||||
@@ -2983,14 +2968,6 @@ function! s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottoml
|
|||||||
return rightMostIndx
|
return rightMostIndx
|
||||||
endfunction
|
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)
|
" Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line)
|
||||||
" This function takes a line and swaps the outer most multi-part delimiters for
|
" This function takes a line and swaps the outer most multi-part delimiters for
|
||||||
" place holders
|
" place holders
|
||||||
|
|||||||
Reference in New Issue
Block a user