mirror of
https://github.com/vim/vim.git
synced 2025-09-04 21:33:48 -04:00
runtime(netrw): save and restore register 0-9, a and unnamed
fixes: #15077 Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
225d4d9212
commit
62f7b55c1a
@ -15,6 +15,7 @@
|
|||||||
" 2024 May 13 by Vim Project: prefer scp over pscp
|
" 2024 May 13 by Vim Project: prefer scp over pscp
|
||||||
" 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915)
|
" 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915)
|
||||||
" 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952)
|
" 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952)
|
||||||
|
" 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077)
|
||||||
" Former Maintainer: Charles E Campbell
|
" Former Maintainer: Charles E Campbell
|
||||||
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
|
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
|
||||||
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
|
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
|
||||||
@ -5573,13 +5574,12 @@ endfun
|
|||||||
" ---------------------------------------------------------------------
|
" ---------------------------------------------------------------------
|
||||||
" netrw#BrowseXVis: used by gx in visual mode to select a file for browsing {{{2
|
" netrw#BrowseXVis: used by gx in visual mode to select a file for browsing {{{2
|
||||||
fun! netrw#BrowseXVis()
|
fun! netrw#BrowseXVis()
|
||||||
" call Dfunc("netrw#BrowseXVis()")
|
let dict={}
|
||||||
let akeep = @a
|
let dict.a=[getreg('a'), getregtype('a')]
|
||||||
norm! gv"ay
|
norm! gv"ay
|
||||||
let gxfile= @a
|
let gxfile= @a
|
||||||
let @a = akeep
|
call s:RestoreRegister(dict)
|
||||||
call netrw#BrowseX(gxfile,netrw#CheckIfRemote(gxfile))
|
call netrw#BrowseX(gxfile,netrw#CheckIfRemote(gxfile))
|
||||||
" call Dret("netrw#BrowseXVis")
|
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
" ---------------------------------------------------------------------
|
||||||
@ -9779,7 +9779,13 @@ fun! s:NetrwWideListing()
|
|||||||
" fpl: filenames per line
|
" fpl: filenames per line
|
||||||
" fpc: filenames per column
|
" fpc: filenames per column
|
||||||
setl ma noro
|
setl ma noro
|
||||||
let keepa= @a
|
let dict={}
|
||||||
|
" save the unnamed register and register 0-9 and a
|
||||||
|
let dict.a=[getreg('a'), getregtype('a')]
|
||||||
|
for i in range(0, 9)
|
||||||
|
let dict[i] = [getreg(i), getregtype(i)]
|
||||||
|
endfor
|
||||||
|
let dict.unnamed = [getreg(''), getregtype('')]
|
||||||
" call Decho("setl ma noro",'~'.expand("<slnum>"))
|
" call Decho("setl ma noro",'~'.expand("<slnum>"))
|
||||||
let b:netrw_cpf= 0
|
let b:netrw_cpf= 0
|
||||||
if line("$") >= w:netrw_bannercnt
|
if line("$") >= w:netrw_bannercnt
|
||||||
@ -9787,7 +9793,8 @@ fun! s:NetrwWideListing()
|
|||||||
exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif'
|
exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif'
|
||||||
NetrwKeepj call histdel("/",-1)
|
NetrwKeepj call histdel("/",-1)
|
||||||
else
|
else
|
||||||
let @a= keepa
|
" restore stored registers
|
||||||
|
call s:RestoreRegister(dict)
|
||||||
" call Dret("NetrwWideListing")
|
" call Dret("NetrwWideListing")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -9839,7 +9846,7 @@ fun! s:NetrwWideListing()
|
|||||||
exe 'nno <buffer> <silent> b :call search(''^.\\|\s\s\zs\S'',''bW'')'."\<cr>"
|
exe 'nno <buffer> <silent> b :call search(''^.\\|\s\s\zs\S'',''bW'')'."\<cr>"
|
||||||
" call Decho("NetrwWideListing) setl noma nomod ro",'~'.expand("<slnum>"))
|
" call Decho("NetrwWideListing) setl noma nomod ro",'~'.expand("<slnum>"))
|
||||||
exe "setl ".g:netrw_bufsettings
|
exe "setl ".g:netrw_bufsettings
|
||||||
let @a= keepa
|
call s:RestoreRegister(dict)
|
||||||
" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
|
" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
|
||||||
" call Dret("NetrwWideListing")
|
" call Dret("NetrwWideListing")
|
||||||
return
|
return
|
||||||
@ -9851,7 +9858,6 @@ fun! s:NetrwWideListing()
|
|||||||
sil! nunmap <buffer> b
|
sil! nunmap <buffer> b
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
" ---------------------------------------------------------------------
|
||||||
@ -10172,7 +10178,8 @@ fun! s:SetupNetrwStatusLine(statline)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" set up User9 highlighting as needed
|
" set up User9 highlighting as needed
|
||||||
let keepa= @a
|
let dict={}
|
||||||
|
let dict.a=[getreg('a'), getregtype('a')]
|
||||||
redir @a
|
redir @a
|
||||||
try
|
try
|
||||||
hi User9
|
hi User9
|
||||||
@ -10184,7 +10191,7 @@ fun! s:SetupNetrwStatusLine(statline)
|
|||||||
endif
|
endif
|
||||||
endtry
|
endtry
|
||||||
redir END
|
redir END
|
||||||
let @a= keepa
|
call s:RestoreRegister(dict)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" set up status line (may use User9 highlighting)
|
" set up status line (may use User9 highlighting)
|
||||||
@ -11994,6 +12001,16 @@ fun! s:RestoreCursorline()
|
|||||||
" call Dret("s:RestoreCursorline : restored cul=".&l:cursorline." cuc=".&l:cursorcolumn)
|
" call Dret("s:RestoreCursorline : restored cul=".&l:cursorline." cuc=".&l:cursorcolumn)
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
|
" s:RestoreRegister: restores all registers given in the dict {{{2
|
||||||
|
fun! s:RestoreRegister(dict)
|
||||||
|
for [key, val] in items(a:dict)
|
||||||
|
if key == 'unnamed'
|
||||||
|
let key = ''
|
||||||
|
endif
|
||||||
|
call setreg(key, val[0], val[1])
|
||||||
|
endfor
|
||||||
|
endfun
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
" ---------------------------------------------------------------------
|
||||||
" s:NetrwDelete: Deletes a file. {{{2
|
" s:NetrwDelete: Deletes a file. {{{2
|
||||||
" Uses Steve Hall's idea to insure that Windows paths stay
|
" Uses Steve Hall's idea to insure that Windows paths stay
|
||||||
|
Loading…
x
Reference in New Issue
Block a user