From 4dcc6409a80d4b36fc2eba4948969e97c467d35b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Oct 2022 22:49:20 +0800 Subject: [PATCH] vim-patch:8.2.1652: cannot translate lines in the options window Problem: Cannot translate lines in the options window. Solution: Use the AddOption() function to split descriptions where indicated by a line break. (issue vim/vim#6800) https://github.com/vim/vim/commit/a953b5cf4f291875b805262eebd361e502de8c92 Co-authored-by: Bram Moolenaar --- runtime/optwin.vim | 52 ++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 6af8abc205..84979092a0 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -20,7 +20,7 @@ let s:cpo_save = &cpo set cpo&vim " function to be called when is hit in the option-window -fun! CR() +func CR() " If on a continued comment line, go back to the first comment line let lnum = search("^[^\t]", 'bWcn') @@ -47,10 +47,10 @@ fun! CR() elseif match(line, '^ \=[0-9]') >= 0 exe "norm! /" . line . "\zt" endif -endfun +endfunc " function to be called when is hit in the option-window -fun! Space() +func Space() let lnum = line(".") let line = getline(lnum) @@ -67,7 +67,7 @@ fun! Space() endif endif -endfun +endfunc let s:local_to_window = gettext('(local to window)') let s:local_to_buffer = gettext('(local to buffer)') @@ -75,7 +75,7 @@ let s:global_or_local = '(global or local to buffer)' " find the window in which the option applies " returns 0 for global option, 1 for local option, -1 for error -fun! Find(lnum) +func Find(lnum) let line = getline(a:lnum - 1) if line =~ s:local_to_window || line =~ s:local_to_buffer let local = 1 @@ -96,10 +96,10 @@ fun! Find(lnum) let local = -1 endif return local -endfun +endfunc " Update a "set" line in the option window -fun! Update(lnum, line, local, thiswin) +func Update(lnum, line, local, thiswin) " get the new value of the option and update the option window line if match(a:line, "=") >= 0 let name = substitute(a:line, '^ \tset \([^=]*\)=.*', '\1', "") @@ -124,7 +124,7 @@ fun! Update(lnum, line, local, thiswin) endif endif set nomodified -endfun +endfunc " Reset 'title' and 'icon' to make it work faster. " Reset 'undolevels' to avoid undo'ing until the buffer is empty. @@ -171,34 +171,34 @@ func AddOption(name, text) endfunc " Init a local binary option -fun! BinOptionL(name) +func BinOptionL(name) let val = getwinvar(winnr('#'), '&' . a:name) call append("$", substitute(substitute(" \tset " . val . a:name . "\t" . \!val . a:name, "0", "no", ""), "1", "", "")) -endfun +endfunc " Init a global binary option -fun! BinOptionG(name, val) +func BinOptionG(name, val) call append("$", substitute(substitute(" \tset " . a:val . a:name . "\t" . \!a:val . a:name, "0", "no", ""), "1", "", "")) -endfun +endfunc " Init a local string option -fun! OptionL(name) +func OptionL(name) let val = escape(getwinvar(winnr('#'), '&' . a:name), " \t\\\"|") call append("$", " \tset " . a:name . "=" . val) -endfun +endfunc " Init a global string option -fun! OptionG(name, val) +func OptionG(name, val) call append("$", " \tset " . a:name . "=" . escape(a:val, " \t\\\"|")) -endfun +endfunc let s:idx = 1 let s:lnum = line("$") call append("$", "") -fun! Header(text) +func Header(text) let line = s:idx . " " . a:text if s:idx < 10 let line = " " . line @@ -209,15 +209,15 @@ fun! Header(text) call append(s:lnum, line) let s:idx = s:idx + 1 let s:lnum = s:lnum + 1 -endfun +endfunc " Get the value of 'pastetoggle'. It could be a special key. -fun! PTvalue() +func PTvalue() redir @a silent set pt redir END return substitute(@a, '[^=]*=\(.*\)', '\1', "") -endfun +endfunc " Restore the previous value of 'cpoptions' here, it's used below. let &cpo = s:cpo_save @@ -249,8 +249,7 @@ call OptionG("hf", &hf) call Header("moving around, searching and patterns") call append("$", "whichwrap\tlist of flags specifying which commands wrap to another line") call OptionG("ww", &ww) -call append("$", "startofline\tmany jump commands move the cursor to the first non-blank") -call append("$", "\tcharacter of a line") +call AddOption("startofline", gettext("many jump commands move the cursor to the first non-blank\ncharacter of a line")) call BinOptionG("sol", &sol) call append("$", "paragraphs\tnroff macro names that separate paragraphs") call OptionG("para", ¶) @@ -297,15 +296,14 @@ endif call Header("tags") -call append("$", "tagbsearch\tuse binary searching in tags files") +call AddOption("tagbsearch", gettext("use binary searching in tags files")) call BinOptionG("tbs", &tbs) call append("$", "taglength\tnumber of significant characters in a tag name or zero") call append("$", " \tset tl=" . &tl) call append("$", "tags\tlist of file names to search for tags") call append("$", "\t(global or local to buffer)") call OptionG("tag", &tag) -call append("$", "tagcase\thow to handle case when searching in tags files:") -call append("$", "\t\"followic\" to follow 'ignorecase', \"ignore\" or \"match\"") +call AddOption("tagcase", gettext("how to handle case when searching in tags files:\n\"followic\" to follow 'ignorecase', \"ignore\" or \"match\"")) call append("$", "\t(global or local to buffer)") call OptionG("tc", &tc) call append("$", "tagrelative\tfile names in a tags file are relative to the tags file") @@ -1306,7 +1304,7 @@ augroup optwin \ call unload() | delfun unload augroup END -fun! unload() +func unload() delfun CR delfun Space delfun Find @@ -1317,7 +1315,7 @@ fun! unload() delfun BinOptionG delfun Header au! optwin -endfun +endfunc " Restore the previous value of 'title' and 'icon'. let &title = s:old_title