mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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 #6800)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
" These commands create the option window.
|
" These commands create the option window.
|
||||||
"
|
"
|
||||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
" Last Change: 2020 aug 30
|
" Last Change: 2020 Sep 10
|
||||||
|
|
||||||
" If there already is an option window, jump to that one.
|
" If there already is an option window, jump to that one.
|
||||||
let buf = bufnr('option-window')
|
let buf = bufnr('option-window')
|
||||||
@@ -20,7 +20,7 @@ let s:cpo_save = &cpo
|
|||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
" function to be called when <CR> is hit in the option-window
|
" function to be called when <CR> is hit in the option-window
|
||||||
fun! <SID>CR()
|
func <SID>CR()
|
||||||
|
|
||||||
" If on a continued comment line, go back to the first comment line
|
" If on a continued comment line, go back to the first comment line
|
||||||
let lnum = search("^[^\t]", 'bWcn')
|
let lnum = search("^[^\t]", 'bWcn')
|
||||||
@@ -47,10 +47,10 @@ fun! <SID>CR()
|
|||||||
elseif match(line, '^ \=[0-9]') >= 0
|
elseif match(line, '^ \=[0-9]') >= 0
|
||||||
exe "norm! /" . line . "\<CR>zt"
|
exe "norm! /" . line . "\<CR>zt"
|
||||||
endif
|
endif
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
" function to be called when <Space> is hit in the option-window
|
" function to be called when <Space> is hit in the option-window
|
||||||
fun! <SID>Space()
|
func <SID>Space()
|
||||||
|
|
||||||
let lnum = line(".")
|
let lnum = line(".")
|
||||||
let line = getline(lnum)
|
let line = getline(lnum)
|
||||||
@@ -67,14 +67,14 @@ fun! <SID>Space()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
let s:local_to_window = gettext('(local to window)')
|
let s:local_to_window = gettext('(local to window)')
|
||||||
let s:local_to_buffer = gettext('(local to buffer)')
|
let s:local_to_buffer = gettext('(local to buffer)')
|
||||||
|
|
||||||
" find the window in which the option applies
|
" find the window in which the option applies
|
||||||
" returns 0 for global option, 1 for local option, -1 for error
|
" returns 0 for global option, 1 for local option, -1 for error
|
||||||
fun! <SID>Find(lnum)
|
func <SID>Find(lnum)
|
||||||
let line = getline(a:lnum - 1)
|
let line = getline(a:lnum - 1)
|
||||||
if line =~ s:local_to_window || line =~ s:local_to_buffer
|
if line =~ s:local_to_window || line =~ s:local_to_buffer
|
||||||
let local = 1
|
let local = 1
|
||||||
@@ -95,10 +95,10 @@ fun! <SID>Find(lnum)
|
|||||||
let local = -1
|
let local = -1
|
||||||
endif
|
endif
|
||||||
return local
|
return local
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
" Update a "set" line in the option window
|
" Update a "set" line in the option window
|
||||||
fun! <SID>Update(lnum, line, local, thiswin)
|
func <SID>Update(lnum, line, local, thiswin)
|
||||||
" get the new value of the option and update the option window line
|
" get the new value of the option and update the option window line
|
||||||
if match(a:line, "=") >= 0
|
if match(a:line, "=") >= 0
|
||||||
let name = substitute(a:line, '^ \tset \([^=]*\)=.*', '\1', "")
|
let name = substitute(a:line, '^ \tset \([^=]*\)=.*', '\1', "")
|
||||||
@@ -123,7 +123,7 @@ fun! <SID>Update(lnum, line, local, thiswin)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
set nomodified
|
set nomodified
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
" Reset 'title' and 'icon' to make it work faster.
|
" Reset 'title' and 'icon' to make it work faster.
|
||||||
" Reset 'undolevels' to avoid undo'ing until the buffer is empty.
|
" Reset 'undolevels' to avoid undo'ing until the buffer is empty.
|
||||||
@@ -159,35 +159,45 @@ call append(6, gettext('" Hit <Space> on a "set" line to refresh it.'))
|
|||||||
|
|
||||||
" These functions are called often below. Keep them fast!
|
" These functions are called often below. Keep them fast!
|
||||||
|
|
||||||
|
" Add an option name and explanation. The text can contain "\n" characters
|
||||||
|
" where a line break is to be inserted.
|
||||||
|
func <SID>AddOption(name, text)
|
||||||
|
let lines = split(a:text, "\n")
|
||||||
|
call append("$", a:name .. "\t" .. lines[0])
|
||||||
|
for line in lines[1:]
|
||||||
|
call append("$", "\t" .. line)
|
||||||
|
endfor
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Init a local binary option
|
" Init a local binary option
|
||||||
fun! <SID>BinOptionL(name)
|
func <SID>BinOptionL(name)
|
||||||
let val = getwinvar(winnr('#'), '&' . a:name)
|
let val = getwinvar(winnr('#'), '&' . a:name)
|
||||||
call append("$", substitute(substitute(" \tset " . val . a:name . "\t" .
|
call append("$", substitute(substitute(" \tset " . val . a:name . "\t" .
|
||||||
\!val . a:name, "0", "no", ""), "1", "", ""))
|
\!val . a:name, "0", "no", ""), "1", "", ""))
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
" Init a global binary option
|
" Init a global binary option
|
||||||
fun! <SID>BinOptionG(name, val)
|
func <SID>BinOptionG(name, val)
|
||||||
call append("$", substitute(substitute(" \tset " . a:val . a:name . "\t" .
|
call append("$", substitute(substitute(" \tset " . a:val . a:name . "\t" .
|
||||||
\!a:val . a:name, "0", "no", ""), "1", "", ""))
|
\!a:val . a:name, "0", "no", ""), "1", "", ""))
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
" Init a local string option
|
" Init a local string option
|
||||||
fun! <SID>OptionL(name)
|
func <SID>OptionL(name)
|
||||||
let val = escape(getwinvar(winnr('#'), '&' . a:name), " \t\\\"|")
|
let val = escape(getwinvar(winnr('#'), '&' . a:name), " \t\\\"|")
|
||||||
call append("$", " \tset " . a:name . "=" . val)
|
call append("$", " \tset " . a:name . "=" . val)
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
" Init a global string option
|
" Init a global string option
|
||||||
fun! <SID>OptionG(name, val)
|
func <SID>OptionG(name, val)
|
||||||
call append("$", " \tset " . a:name . "=" . escape(a:val, " \t\\\"|"))
|
call append("$", " \tset " . a:name . "=" . escape(a:val, " \t\\\"|"))
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
let s:idx = 1
|
let s:idx = 1
|
||||||
let s:lnum = line("$")
|
let s:lnum = line("$")
|
||||||
call append("$", "")
|
call append("$", "")
|
||||||
|
|
||||||
fun! <SID>Header(text)
|
func <SID>Header(text)
|
||||||
let line = s:idx . " " . a:text
|
let line = s:idx . " " . a:text
|
||||||
if s:idx < 10
|
if s:idx < 10
|
||||||
let line = " " . line
|
let line = " " . line
|
||||||
@@ -198,15 +208,15 @@ fun! <SID>Header(text)
|
|||||||
call append(s:lnum, line)
|
call append(s:lnum, line)
|
||||||
let s:idx = s:idx + 1
|
let s:idx = s:idx + 1
|
||||||
let s:lnum = s:lnum + 1
|
let s:lnum = s:lnum + 1
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
" Get the value of 'pastetoggle'. It could be a special key.
|
" Get the value of 'pastetoggle'. It could be a special key.
|
||||||
fun! <SID>PTvalue()
|
func <SID>PTvalue()
|
||||||
redir @a
|
redir @a
|
||||||
silent set pt
|
silent set pt
|
||||||
redir END
|
redir END
|
||||||
return substitute(@a, '[^=]*=\(.*\)', '\1', "")
|
return substitute(@a, '[^=]*=\(.*\)', '\1', "")
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
" Restore the previous value of 'cpoptions' here, it's used below.
|
" Restore the previous value of 'cpoptions' here, it's used below.
|
||||||
let &cpo = s:cpo_save
|
let &cpo = s:cpo_save
|
||||||
@@ -240,8 +250,7 @@ call <SID>OptionG("hf", &hf)
|
|||||||
call <SID>Header("moving around, searching and patterns")
|
call <SID>Header("moving around, searching and patterns")
|
||||||
call append("$", "whichwrap\tlist of flags specifying which commands wrap to another line")
|
call append("$", "whichwrap\tlist of flags specifying which commands wrap to another line")
|
||||||
call <SID>OptionG("ww", &ww)
|
call <SID>OptionG("ww", &ww)
|
||||||
call append("$", "startofline\tmany jump commands move the cursor to the first non-blank")
|
call <SID>AddOption("startofline", gettext("many jump commands move the cursor to the first non-blank\ncharacter of a line"))
|
||||||
call append("$", "\tcharacter of a line")
|
|
||||||
call <SID>BinOptionG("sol", &sol)
|
call <SID>BinOptionG("sol", &sol)
|
||||||
call append("$", "paragraphs\tnroff macro names that separate paragraphs")
|
call append("$", "paragraphs\tnroff macro names that separate paragraphs")
|
||||||
call <SID>OptionG("para", ¶)
|
call <SID>OptionG("para", ¶)
|
||||||
@@ -286,15 +295,14 @@ endif
|
|||||||
|
|
||||||
|
|
||||||
call <SID>Header("tags")
|
call <SID>Header("tags")
|
||||||
call append("$", "tagbsearch\tuse binary searching in tags files")
|
call <SID>AddOption("tagbsearch", gettext("use binary searching in tags files"))
|
||||||
call <SID>BinOptionG("tbs", &tbs)
|
call <SID>BinOptionG("tbs", &tbs)
|
||||||
call append("$", "taglength\tnumber of significant characters in a tag name or zero")
|
call append("$", "taglength\tnumber of significant characters in a tag name or zero")
|
||||||
call append("$", " \tset tl=" . &tl)
|
call append("$", " \tset tl=" . &tl)
|
||||||
call append("$", "tags\tlist of file names to search for tags")
|
call append("$", "tags\tlist of file names to search for tags")
|
||||||
call append("$", "\t(global or local to buffer)")
|
call append("$", "\t(global or local to buffer)")
|
||||||
call <SID>OptionG("tag", &tag)
|
call <SID>OptionG("tag", &tag)
|
||||||
call append("$", "tagcase\thow to handle case when searching in tags files:")
|
call <SID>AddOption("tagcase", gettext("how to handle case when searching in tags files:\n\"followic\" to follow 'ignorecase', \"ignore\" or \"match\""))
|
||||||
call append("$", "\t\"followic\" to follow 'ignorecase', \"ignore\" or \"match\"")
|
|
||||||
call append("$", "\t(global or local to buffer)")
|
call append("$", "\t(global or local to buffer)")
|
||||||
call <SID>OptionG("tc", &tc)
|
call <SID>OptionG("tc", &tc)
|
||||||
call append("$", "tagrelative\tfile names in a tags file are relative to the tags file")
|
call append("$", "tagrelative\tfile names in a tags file are relative to the tags file")
|
||||||
@@ -1446,7 +1454,7 @@ augroup optwin
|
|||||||
\ call <SID>unload() | delfun <SID>unload
|
\ call <SID>unload() | delfun <SID>unload
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
fun! <SID>unload()
|
func <SID>unload()
|
||||||
delfun <SID>CR
|
delfun <SID>CR
|
||||||
delfun <SID>Space
|
delfun <SID>Space
|
||||||
delfun <SID>Find
|
delfun <SID>Find
|
||||||
@@ -1457,7 +1465,7 @@ fun! <SID>unload()
|
|||||||
delfun <SID>BinOptionG
|
delfun <SID>BinOptionG
|
||||||
delfun <SID>Header
|
delfun <SID>Header
|
||||||
au! optwin
|
au! optwin
|
||||||
endfun
|
endfunc
|
||||||
|
|
||||||
" Restore the previous value of 'title' and 'icon'.
|
" Restore the previous value of 'title' and 'icon'.
|
||||||
let &title = s:old_title
|
let &title = s:old_title
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1652,
|
||||||
/**/
|
/**/
|
||||||
1651,
|
1651,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user