Franklin, Jason
unread,Apr 9, 2020, 4:34:48 PM4/9/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to vim...@googlegroups.com
Greetings:
Every time the ":Man" command is executed, it will overwrite the unnamed
register. See the test in the patch below for the reproduction.
diff --git a/runtime/ftplugin/man.vim b/runtime/ftplugin/man.vim
index d7ce4d8ac..1c13c8065 100644
--- a/runtime/ftplugin/man.vim
+++ b/runtime/ftplugin/man.vim
@@ -189,7 +189,7 @@ func <SID>GetPage(cmdmods, ...)
setl buftype=nofile noswapfile
setl fdc=0 ma nofen nonu nornu
- silent exec "norm! 1GdG"
+ %delete _
let unsetwidth = 0
if empty($MANWIDTH)
let $MANWIDTH = winwidth(0)
@@ -213,10 +213,10 @@ func <SID>GetPage(cmdmods, ...)
endif
" Remove blank lines from top and bottom.
while line('$') > 1 && getline(1) =~ '^\s*$'
- silent keepj norm! ggdd
+ 1delete _
endwhile
while line('$') > 1 && getline('$') =~ '^\s*$'
- silent keepj norm! Gdd
+ $delete _
endwhile
1
setl ft=man nomod
diff --git a/src/testdir/test_man.vim b/src/testdir/test_man.vim
index 9de8cb474..b2fe460d6 100644
--- a/src/testdir/test_man.vim
+++ b/src/testdir/test_man.vim
@@ -111,3 +111,21 @@ func Test_local_options()
%bw!
set foldcolumn& number&
endfunc
+
+" Check that the unnamed register is not overwritten.
+func Test_keep_unnamed_register()
+ %bw!
+
+ let @" = '---'
+
+ let wincnt = winnr('$')
+ Man vim
+ if wincnt == winnr('$')
+ " Vim manual page cannot be found.
+ return
+ endif
+
+ call assert_equal('---', @")
+
+ %bw!
+endfunc
--
Jason Franklin