diff --git a/runtime/colors/blue.vim b/runtime/colors/blue.vim index ba1f68be52..7ac44c868c 100644 --- a/runtime/colors/blue.vim +++ b/runtime/colors/blue.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Steven Vertigan " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:34 MSK +" Last Updated: Fri 02 Sep 2022 09:41:44 MSK " Generated by Colortemplate v2.2.0 @@ -57,7 +57,7 @@ hi ToolbarLine guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NO hi VertSplit guifg=#008787 guibg=NONE gui=NONE cterm=NONE hi Visual guifg=#ffffff guibg=#008787 gui=NONE cterm=NONE hi VisualNOS guifg=#008787 guibg=#ffffff gui=NONE cterm=NONE -hi WarningMsg guifg=#d70000 guibg=NONE gui=NONE cterm=NONE +hi WarningMsg guifg=#d787d7 guibg=NONE gui=NONE cterm=NONE hi WildMenu guifg=#000087 guibg=#ffd700 gui=NONE cterm=NONE hi debugBreakpoint guifg=#00ff00 guibg=#000087 gui=reverse cterm=reverse hi debugPC guifg=#5fffff guibg=#000087 gui=reverse cterm=reverse @@ -120,6 +120,8 @@ hi! link Structure Type hi! link Tag Special hi! link Typedef Type hi! link Terminal Normal +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi DiffAdd guifg=#ffffff guibg=#5f875f gui=NONE cterm=NONE hi DiffChange guifg=#ffffff guibg=#5f87af gui=NONE cterm=NONE hi DiffText guifg=#000000 guibg=#c6c6c6 gui=NONE cterm=NONE @@ -165,7 +167,7 @@ if s:t_Co >= 256 hi VertSplit ctermfg=30 ctermbg=NONE cterm=NONE hi Visual ctermfg=231 ctermbg=30 cterm=NONE hi VisualNOS ctermfg=30 ctermbg=231 cterm=NONE - hi WarningMsg ctermfg=160 ctermbg=NONE cterm=NONE + hi WarningMsg ctermfg=176 ctermbg=NONE cterm=NONE hi WildMenu ctermfg=18 ctermbg=220 cterm=NONE hi debugBreakpoint ctermfg=46 ctermbg=18 cterm=reverse hi debugPC ctermfg=87 ctermbg=18 cterm=reverse @@ -228,6 +230,8 @@ if s:t_Co >= 256 hi! link Tag Special hi! link Typedef Type hi! link Terminal Normal + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi DiffAdd ctermfg=231 ctermbg=65 cterm=NONE hi DiffChange ctermfg=231 ctermbg=67 cterm=NONE hi DiffText ctermfg=16 ctermbg=251 cterm=NONE @@ -276,7 +280,7 @@ if s:t_Co >= 16 hi VertSplit ctermfg=darkcyan ctermbg=NONE cterm=NONE hi Visual ctermfg=white ctermbg=darkcyan cterm=NONE hi VisualNOS ctermfg=darkcyan ctermbg=white cterm=NONE - hi WarningMsg ctermfg=red ctermbg=NONE cterm=NONE + hi WarningMsg ctermfg=magenta ctermbg=NONE cterm=NONE hi WildMenu ctermfg=darkblue ctermbg=yellow cterm=NONE hi debugBreakpoint ctermfg=green ctermbg=darkblue cterm=reverse hi debugPC ctermfg=cyan ctermbg=darkblue cterm=reverse @@ -339,6 +343,8 @@ if s:t_Co >= 16 hi! link Tag Special hi! link Typedef Type hi! link Terminal Normal + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi DiffAdd ctermfg=white ctermbg=darkgreen cterm=NONE hi DiffChange ctermfg=white ctermbg=blue cterm=NONE hi DiffText ctermfg=black ctermbg=grey cterm=NONE @@ -449,6 +455,8 @@ if s:t_Co >= 8 hi! link Tag Special hi! link Typedef Type hi! link Terminal Normal + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi DiffAdd ctermfg=white ctermbg=darkgreen cterm=NONE hi DiffChange ctermfg=white ctermbg=darkblue cterm=NONE hi DiffText ctermfg=black ctermbg=grey cterm=NONE diff --git a/runtime/colors/darkblue.vim b/runtime/colors/darkblue.vim index 88a6c41847..140e7d47c9 100644 --- a/runtime/colors/darkblue.vim +++ b/runtime/colors/darkblue.vim @@ -4,7 +4,7 @@ " Maintainer: Original author Bohdan Vlasyuk " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:35 MSK +" Last Updated: Fri 02 Sep 2022 09:40:36 MSK " Generated by Colortemplate v2.2.0 @@ -65,6 +65,8 @@ hi! link diffCommon WarningMsg hi! link diffBDiffer WarningMsg hi! link lCursor Cursor hi! link CurSearch Search +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#c0c0c0 guibg=#000040 gui=NONE cterm=NONE hi Conceal guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE hi ColorColumn guifg=#c0c0c0 guibg=#8b0000 gui=NONE cterm=NONE @@ -171,6 +173,8 @@ if s:t_Co >= 256 hi! link diffBDiffer WarningMsg hi! link lCursor Cursor hi! link CurSearch Search + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=252 ctermbg=17 cterm=NONE hi Conceal ctermfg=NONE ctermbg=NONE cterm=NONE hi ColorColumn ctermfg=252 ctermbg=88 cterm=NONE diff --git a/runtime/colors/delek.vim b/runtime/colors/delek.vim index ebaf12f570..9543b568f6 100644 --- a/runtime/colors/delek.vim +++ b/runtime/colors/delek.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer David Schweikert " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:36 MSK +" Last Updated: Sun 04 Sep 2022 09:31:26 MSK " Generated by Colortemplate v2.2.0 @@ -25,6 +25,8 @@ hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine hi! link ErrorMsg Error +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#000000 guibg=#ffffff gui=NONE cterm=NONE hi EndOfBuffer guifg=#bcbcbc guibg=NONE gui=NONE cterm=NONE hi StatusLine guifg=#ffff00 guibg=#00008b gui=bold cterm=bold @@ -57,7 +59,7 @@ hi Error guifg=#ff0000 guibg=#ffffff gui=reverse cterm=reverse hi WarningMsg guifg=#cd00cd guibg=#ffffff gui=NONE cterm=NONE hi MoreMsg guifg=#000000 guibg=#ffffff gui=bold cterm=bold hi ModeMsg guifg=#000000 guibg=#ffffff gui=bold cterm=bold -hi Question guifg=#00cd00 guibg=NONE gui=bold cterm=bold +hi Question guifg=#008700 guibg=NONE gui=bold cterm=bold hi Todo guifg=#000000 guibg=#ffff00 gui=NONE cterm=NONE hi MatchParen guifg=#ffffff guibg=#ff1493 gui=NONE cterm=NONE hi Search guifg=#ffffff guibg=#cd00cd gui=NONE cterm=NONE @@ -97,6 +99,8 @@ if s:t_Co >= 256 hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine hi! link ErrorMsg Error + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=16 ctermbg=231 cterm=NONE hi EndOfBuffer ctermfg=250 ctermbg=NONE cterm=NONE hi StatusLine ctermfg=226 ctermbg=18 cterm=bold @@ -129,7 +133,7 @@ if s:t_Co >= 256 hi WarningMsg ctermfg=164 ctermbg=231 cterm=NONE hi MoreMsg ctermfg=16 ctermbg=231 cterm=bold hi ModeMsg ctermfg=16 ctermbg=231 cterm=bold - hi Question ctermfg=40 ctermbg=NONE cterm=bold + hi Question ctermfg=28 ctermbg=NONE cterm=bold hi Todo ctermfg=16 ctermbg=226 cterm=NONE hi MatchParen ctermfg=231 ctermbg=198 cterm=NONE hi Search ctermfg=231 ctermbg=164 cterm=NONE diff --git a/runtime/colors/desert.vim b/runtime/colors/desert.vim index 152384e3a0..41ed976fa4 100644 --- a/runtime/colors/desert.vim +++ b/runtime/colors/desert.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Hans Fugal " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:37 MSK +" Last Updated: Fri 02 Sep 2022 09:39:21 MSK " Generated by Colortemplate v2.2.0 @@ -25,6 +25,8 @@ hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine hi! link EndOfBuffer NonText +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#ffffff guibg=#333333 gui=NONE cterm=NONE hi StatusLine guifg=#333333 guibg=#c2bfa5 gui=NONE cterm=NONE hi StatusLineNC guifg=#7f7f8c guibg=#c2bfa5 gui=NONE cterm=NONE @@ -97,6 +99,8 @@ if s:t_Co >= 256 hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine hi! link EndOfBuffer NonText + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=231 ctermbg=236 cterm=NONE hi StatusLine ctermfg=236 ctermbg=144 cterm=NONE hi StatusLineNC ctermfg=242 ctermbg=144 cterm=NONE diff --git a/runtime/colors/elflord.vim b/runtime/colors/elflord.vim index 2cda253593..e9efd3de59 100644 --- a/runtime/colors/elflord.vim +++ b/runtime/colors/elflord.vim @@ -3,7 +3,7 @@ " Maintainer: original maintainer Ron Aaron " Website: https://www.github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:37 MSK +" Last Updated: Fri 02 Sep 2022 09:44:22 MSK " Generated by Colortemplate v2.2.0 @@ -43,6 +43,8 @@ hi! link lCursor Cursor hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo if (has('termguicolors') && &termguicolors) || has('gui_running') let g:terminal_ansi_colors = ['#000000', '#cd0000', '#00cd00', '#cdcd00', '#0000ee', '#cd00cd', '#00cdcd', '#e5e5e5', '#7f7f7f', '#ff0000', '#00ff00', '#ffff00', '#5c5cff', '#ff00ff', '#00ffff', '#ffffff'] diff --git a/runtime/colors/evening.vim b/runtime/colors/evening.vim index c2043b641a..be6c43ff34 100644 --- a/runtime/colors/evening.vim +++ b/runtime/colors/evening.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Steven Vertigan " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:38 MSK +" Last Updated: Sun 04 Sep 2022 09:48:34 MSK " Generated by Colortemplate v2.2.0 @@ -16,7 +16,7 @@ let g:colors_name = 'evening' let s:t_Co = exists('&t_Co') && !has('gui_running') ? (&t_Co ?? 0) : -1 if (has('termguicolors') && &termguicolors) || has('gui_running') - let g:terminal_ansi_colors = ['#000000', '#ffa500', '#2e8b57', '#ffff00', '#006faf', '#8b008b', '#008b8b', '#bebebe', '#4d4d4d', '#ff5f5f', '#00ff00', '#ffff60', '#0087ff', '#ff80ff', '#00ffff', '#ffffff'] + let g:terminal_ansi_colors = ['#000000', '#cd0000', '#00cd00', '#cdcd00', '#0087ff', '#cd00cd', '#00cdcd', '#e5e5e5', '#7f7f7f', '#ff0000', '#00ff00', '#ffff00', '#5c5cff', '#ff00ff', '#00ffff', '#ffffff'] endif hi! link VertSplit StatusLineNC hi! link StatusLineTerm StatusLine @@ -64,6 +64,8 @@ hi! link String Constant hi! link Structure Type hi! link Tag Special hi! link Typedef Type +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#ffffff guibg=#333333 gui=NONE cterm=NONE hi ColorColumn guifg=NONE guibg=#8b0000 gui=NONE cterm=NONE hi CursorLine guifg=NONE guibg=#666666 gui=NONE cterm=NONE @@ -98,7 +100,7 @@ hi ToolbarButton guifg=NONE guibg=#999999 gui=bold cterm=bold hi ToolbarLine guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE hi Visual guifg=#ffffff guibg=#999999 gui=NONE cterm=NONE hi VisualNOS guifg=NONE guibg=NONE gui=bold,underline ctermfg=NONE ctermbg=NONE cterm=bold,underline -hi WarningMsg guifg=#8b0000 guibg=NONE gui=NONE cterm=NONE +hi WarningMsg guifg=#ff0000 guibg=NONE gui=NONE cterm=NONE hi WildMenu guifg=#000000 guibg=#ffff00 gui=bold cterm=bold hi debugBreakpoint guifg=#00008b guibg=#ff0000 gui=NONE cterm=NONE hi debugPC guifg=#00008b guibg=#0000ff gui=NONE cterm=NONE @@ -170,6 +172,8 @@ if s:t_Co >= 256 hi! link Structure Type hi! link Tag Special hi! link Typedef Type + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=231 ctermbg=236 cterm=NONE hi ColorColumn ctermfg=NONE ctermbg=88 cterm=NONE hi CursorLine ctermfg=NONE ctermbg=241 cterm=NONE @@ -204,7 +208,7 @@ if s:t_Co >= 256 hi ToolbarLine ctermfg=NONE ctermbg=NONE cterm=NONE hi Visual ctermfg=231 ctermbg=246 cterm=NONE hi VisualNOS ctermfg=NONE ctermbg=NONE cterm=bold,underline - hi WarningMsg ctermfg=88 ctermbg=NONE cterm=NONE + hi WarningMsg ctermfg=196 ctermbg=NONE cterm=NONE hi WildMenu ctermfg=16 ctermbg=226 cterm=bold hi debugBreakpoint ctermfg=18 ctermbg=196 cterm=NONE hi debugPC ctermfg=18 ctermbg=21 cterm=NONE @@ -279,6 +283,8 @@ if s:t_Co >= 16 hi! link Structure Type hi! link Tag Special hi! link Typedef Type + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=white ctermbg=black cterm=NONE hi ColorColumn ctermfg=white ctermbg=darkred cterm=NONE hi CursorLine ctermfg=NONE ctermbg=NONE cterm=underline @@ -313,7 +319,7 @@ if s:t_Co >= 16 hi ToolbarLine ctermfg=NONE ctermbg=NONE cterm=NONE hi Visual ctermfg=white ctermbg=darkgray cterm=NONE hi VisualNOS ctermfg=NONE ctermbg=NONE cterm=bold,underline - hi WarningMsg ctermfg=darkred ctermbg=NONE cterm=NONE + hi WarningMsg ctermfg=red ctermbg=NONE cterm=NONE hi WildMenu ctermfg=black ctermbg=darkyellow cterm=bold hi debugBreakpoint ctermfg=darkblue ctermbg=red cterm=NONE hi debugPC ctermfg=darkblue ctermbg=blue cterm=NONE @@ -494,13 +500,26 @@ endif " Color: grey30 #4d4d4d 239 darkgray " Color: grey40 #666666 241 darkgray " Color: grey60 #999999 246 darkgray -" Color: xtermblue #0087ff 33 blue -" Color: xtermdarkblue #006faf 25 darkblue -" Color: xtermred #ff5f5f 203 red " Color: comment #80a0ff 111 lightblue " Color: darkred #8b0000 88 darkred -" Term colors: black orange seagreen yellow xtermdarkblue darkmagenta darkcyan grey -" Term colors: grey30 xtermred green lightyellow xtermblue magenta cyan white +" Color: x_black #000000 16 black +" Color: x_darkred #cd0000 160 darkred +" Color: x_darkgreen #00cd00 40 darkgreen +" Color: x_darkyellow #cdcd00 184 darkyellow +" Color: x_darkblue_m #0087ff 33 darkblue +" Color: x_darkmagenta #cd00cd 164 darkmagenta +" Color: x_darkcyan #00cdcd 44 darkcyan +" Color: x_gray #e5e5e5 254 gray +" Color: x_darkgray #7f7f7f 244 darkgray +" Color: x_red #ff0000 196 red +" Color: x_green #00ff00 46 green +" Color: x_yellow #ffff00 226 yellow +" Color: x_blue #5c5cff 63 blue +" Color: x_magenta #ff00ff 201 magenta +" Color: x_cyan #00ffff 51 cyan +" Color: x_white #ffffff 231 white +" Term colors: x_black x_darkred x_darkgreen x_darkyellow x_darkblue_m x_darkmagenta x_darkcyan x_gray +" Term colors: x_darkgray x_red x_green x_yellow x_blue x_magenta x_cyan x_white " Color: bgDiffA #5F875F 65 darkgreen " Color: bgDiffC #5F87AF 67 blue " Color: bgDiffD #AF5FAF 133 magenta diff --git a/runtime/colors/habamax.vim b/runtime/colors/habamax.vim index ad84f4db32..e3e7202ed3 100644 --- a/runtime/colors/habamax.vim +++ b/runtime/colors/habamax.vim @@ -4,7 +4,7 @@ " Maintainer: Maxim Kim " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:38 MSK +" Last Updated: Fri 02 Sep 2022 09:45:11 MSK " Generated by Colortemplate v2.2.0 @@ -21,6 +21,8 @@ endif hi! link Terminal Normal hi! link StatuslineTerm Statusline hi! link StatuslineTermNC StatuslineNC +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi! link javaScriptFunction Statement hi! link javaScriptIdentifier Statement hi! link sqlKeyword Statement @@ -142,6 +144,8 @@ if s:t_Co >= 256 hi! link Terminal Normal hi! link StatuslineTerm Statusline hi! link StatuslineTermNC StatuslineNC + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi! link javaScriptFunction Statement hi! link javaScriptIdentifier Statement hi! link sqlKeyword Statement diff --git a/runtime/colors/industry.vim b/runtime/colors/industry.vim index 07d15d3960..0946fe996b 100644 --- a/runtime/colors/industry.vim +++ b/runtime/colors/industry.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Shian Lee. " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:39 MSK +" Last Updated: Sun 04 Sep 2022 09:50:04 MSK " Generated by Colortemplate v2.2.0 @@ -51,7 +51,7 @@ hi Underlined guifg=#87afff guibg=NONE gui=underline cterm=underline hi Error guifg=#ffffff guibg=#ff0000 gui=NONE cterm=NONE hi ErrorMsg guifg=#ffffff guibg=#ff0000 gui=NONE cterm=NONE hi ModeMsg guifg=#ffffff guibg=NONE gui=bold cterm=bold -hi WarningMsg guifg=#870000 guibg=NONE gui=bold cterm=bold +hi WarningMsg guifg=#ff0000 guibg=NONE gui=bold cterm=bold hi MoreMsg guifg=#5fd75f guibg=NONE gui=bold cterm=bold hi Question guifg=#00ff00 guibg=NONE gui=bold cterm=bold hi Todo guifg=#005fff guibg=#ffff00 gui=NONE cterm=NONE @@ -84,6 +84,8 @@ hi! link LineNrBelow LineNr hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi DiffAdd guifg=#ffffff guibg=#5f875f gui=NONE cterm=NONE hi DiffChange guifg=#ffffff guibg=#5f87af gui=NONE cterm=NONE hi DiffText guifg=#000000 guibg=#c6c6c6 gui=NONE cterm=NONE @@ -123,7 +125,7 @@ if s:t_Co >= 256 hi Error ctermfg=231 ctermbg=196 cterm=NONE hi ErrorMsg ctermfg=231 ctermbg=196 cterm=NONE hi ModeMsg ctermfg=231 ctermbg=NONE cterm=bold - hi WarningMsg ctermfg=88 ctermbg=NONE cterm=bold + hi WarningMsg ctermfg=196 ctermbg=NONE cterm=bold hi MoreMsg ctermfg=77 ctermbg=NONE cterm=bold hi Question ctermfg=46 ctermbg=NONE cterm=bold hi Todo ctermfg=27 ctermbg=226 cterm=NONE @@ -156,6 +158,8 @@ if s:t_Co >= 256 hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi DiffAdd ctermfg=231 ctermbg=65 cterm=NONE hi DiffChange ctermfg=231 ctermbg=67 cterm=NONE hi DiffText ctermfg=16 ctermbg=251 cterm=NONE @@ -198,7 +202,7 @@ if s:t_Co >= 16 hi Error ctermfg=white ctermbg=red cterm=NONE hi ErrorMsg ctermfg=white ctermbg=red cterm=NONE hi ModeMsg ctermfg=white ctermbg=NONE cterm=bold - hi WarningMsg ctermfg=darkred ctermbg=NONE cterm=bold + hi WarningMsg ctermfg=red ctermbg=NONE cterm=bold hi MoreMsg ctermfg=darkgreen ctermbg=NONE cterm=bold hi Question ctermfg=green ctermbg=NONE cterm=bold hi Todo ctermfg=blue ctermbg=yellow cterm=NONE @@ -231,6 +235,8 @@ if s:t_Co >= 16 hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi DiffAdd ctermfg=white ctermbg=darkgreen cterm=NONE hi DiffChange ctermfg=white ctermbg=blue cterm=NONE hi DiffText ctermfg=black ctermbg=grey cterm=NONE diff --git a/runtime/colors/koehler.vim b/runtime/colors/koehler.vim index 69b10c6f38..2505e8ec47 100644 --- a/runtime/colors/koehler.vim +++ b/runtime/colors/koehler.vim @@ -3,7 +3,7 @@ " Maintainer: original maintainer Ron Aaron " Website: https://www.github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:39 MSK +" Last Updated: Fri 02 Sep 2022 09:23:56 MSK " Generated by Colortemplate v2.2.0 @@ -49,6 +49,8 @@ hi! link lCursor Cursor hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo if (has('termguicolors') && &termguicolors) || has('gui_running') let g:terminal_ansi_colors = ['#000000', '#cd0000', '#00cd00', '#cdcd00', '#0000ee', '#cd00cd', '#00cdcd', '#e5e5e5', '#7f7f7f', '#ff0000', '#00ff00', '#ffff00', '#5c5cff', '#ff00ff', '#00ffff', '#ffffff'] diff --git a/runtime/colors/lunaperche.vim b/runtime/colors/lunaperche.vim index 982d93c36d..7ec3de109f 100644 --- a/runtime/colors/lunaperche.vim +++ b/runtime/colors/lunaperche.vim @@ -4,7 +4,7 @@ " Maintainer: Maxim Kim " Website: https://www.github.com/vim/colorschemes " License: Vim License (see `:help license`) -" Last Updated: Tue 23 Aug 2022 16:50:40 MSK +" Last Updated: Sat 03 Sep 2022 14:31:51 MSK " Generated by Colortemplate v2.2.0 @@ -81,18 +81,31 @@ hi! link shOption Normal hi! link shCommandSub Normal hi! link shDerefPattern shQuote hi! link shDerefOp Special +hi! link phpStorageClass Statement +hi! link phpStructure Statement +hi! link phpInclude Statement +hi! link phpDefine Statement +hi! link phpSpecialFunction Normal +hi! link phpParent Normal +hi! link phpComparison Normal +hi! link phpOperator Normal +hi! link phpVarSelector Special +hi! link phpMemberSelector Special +hi! link phpDocCustomTags phpDocTags hi! link Terminal Normal hi! link StatuslineTerm Statusline hi! link StatuslineTermNC StatuslineNC hi! link LineNrAbove LineNr hi! link LineNrBelow LineNr +hi! link MessageWindow PMenu +hi! link PopupNotification Todo if &background ==# 'dark' if (has('termguicolors') && &termguicolors) || has('gui_running') let g:terminal_ansi_colors = ['#000000', '#af5f5f', '#5faf5f', '#af875f', '#5f87af', '#d787af', '#5fafaf', '#c6c6c6', '#767676', '#ff5f5f', '#5fd75f', '#ffd787', '#87afd7', '#ffafd7', '#5fd7d7', '#ffffff'] endif hi Normal guifg=#c6c6c6 guibg=#000000 gui=NONE cterm=NONE - hi Statusline guifg=#000000 guibg=#c6c6c6 gui=bold cterm=bold - hi StatuslineNC guifg=#000000 guibg=#767676 gui=NONE cterm=NONE + hi Statusline guifg=#c6c6c6 guibg=#000000 gui=bold,reverse cterm=bold,reverse + hi StatuslineNC guifg=#767676 guibg=#000000 gui=reverse cterm=reverse hi VertSplit guifg=#767676 guibg=#767676 gui=NONE cterm=NONE hi TabLine guifg=#000000 guibg=#c6c6c6 gui=NONE cterm=NONE hi TabLineFill guifg=NONE guibg=#767676 gui=NONE cterm=NONE @@ -107,7 +120,7 @@ if &background ==# 'dark' hi EndOfBuffer guifg=#585858 guibg=NONE gui=NONE cterm=NONE hi SpecialKey guifg=#585858 guibg=NONE gui=NONE cterm=NONE hi Pmenu guifg=NONE guibg=#1c1c1c gui=NONE cterm=NONE - hi PmenuSel guifg=NONE guibg=#005f00 gui=NONE cterm=NONE + hi PmenuSel guifg=NONE guibg=#444444 gui=NONE cterm=NONE hi PmenuThumb guifg=NONE guibg=#c6c6c6 gui=NONE cterm=NONE hi PmenuSbar guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE hi SignColumn guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE @@ -169,7 +182,6 @@ if &background ==# 'dark' hi dirFilterMenuBookmarkPath guifg=#878787 guibg=NONE gui=NONE cterm=NONE hi dirFilterMenuHistoryPath guifg=#878787 guibg=NONE gui=NONE cterm=NONE hi FilterMenuLineNr guifg=#878787 guibg=NONE gui=NONE cterm=NONE - hi CocMenuSel guifg=NONE guibg=#005f00 gui=NONE cterm=NONE hi CocSearch guifg=#ffd787 guibg=NONE gui=NONE cterm=NONE else " Light background @@ -193,7 +205,7 @@ else hi EndOfBuffer guifg=#9e9e9e guibg=NONE gui=NONE cterm=NONE hi SpecialKey guifg=#9e9e9e guibg=NONE gui=NONE cterm=NONE hi Pmenu guifg=NONE guibg=#eeeeee gui=NONE cterm=NONE - hi PmenuSel guifg=NONE guibg=#afd7af gui=NONE cterm=NONE + hi PmenuSel guifg=NONE guibg=#c6c6c6 gui=NONE cterm=NONE hi PmenuThumb guifg=NONE guibg=#767676 gui=NONE cterm=NONE hi PmenuSbar guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE hi SignColumn guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE @@ -256,7 +268,6 @@ else hi dirFilterMenuHistoryPath guifg=#626262 guibg=NONE gui=NONE cterm=NONE hi FilterMenuDirectorySubtle guifg=#626262 guibg=NONE gui=NONE cterm=NONE hi FilterMenuLineNr guifg=#626262 guibg=NONE gui=NONE cterm=NONE - hi CocMenuSel guifg=NONE guibg=#afd7af gui=NONE cterm=NONE hi CocSearch guifg=#870000 guibg=NONE gui=NONE cterm=NONE endif @@ -329,15 +340,28 @@ if s:t_Co >= 256 hi! link shCommandSub Normal hi! link shDerefPattern shQuote hi! link shDerefOp Special + hi! link phpStorageClass Statement + hi! link phpStructure Statement + hi! link phpInclude Statement + hi! link phpDefine Statement + hi! link phpSpecialFunction Normal + hi! link phpParent Normal + hi! link phpComparison Normal + hi! link phpOperator Normal + hi! link phpVarSelector Special + hi! link phpMemberSelector Special + hi! link phpDocCustomTags phpDocTags hi! link Terminal Normal hi! link StatuslineTerm Statusline hi! link StatuslineTermNC StatuslineNC hi! link LineNrAbove LineNr hi! link LineNrBelow LineNr + hi! link MessageWindow PMenu + hi! link PopupNotification Todo if &background ==# 'dark' hi Normal ctermfg=251 ctermbg=16 cterm=NONE - hi Statusline ctermfg=16 ctermbg=251 cterm=bold - hi StatuslineNC ctermfg=16 ctermbg=243 cterm=NONE + hi Statusline ctermfg=251 ctermbg=16 cterm=bold,reverse + hi StatuslineNC ctermfg=243 ctermbg=16 cterm=reverse hi VertSplit ctermfg=243 ctermbg=243 cterm=NONE hi TabLine ctermfg=16 ctermbg=251 cterm=NONE hi TabLineFill ctermfg=NONE ctermbg=243 cterm=NONE @@ -352,7 +376,7 @@ if s:t_Co >= 256 hi EndOfBuffer ctermfg=240 ctermbg=NONE cterm=NONE hi SpecialKey ctermfg=240 ctermbg=NONE cterm=NONE hi Pmenu ctermfg=NONE ctermbg=234 cterm=NONE - hi PmenuSel ctermfg=NONE ctermbg=22 cterm=NONE + hi PmenuSel ctermfg=NONE ctermbg=238 cterm=NONE hi PmenuThumb ctermfg=NONE ctermbg=251 cterm=NONE hi PmenuSbar ctermfg=NONE ctermbg=NONE cterm=NONE hi SignColumn ctermfg=NONE ctermbg=NONE cterm=NONE @@ -412,7 +436,6 @@ if s:t_Co >= 256 hi dirFilterMenuBookmarkPath ctermfg=102 ctermbg=NONE cterm=NONE hi dirFilterMenuHistoryPath ctermfg=102 ctermbg=NONE cterm=NONE hi FilterMenuLineNr ctermfg=102 ctermbg=NONE cterm=NONE - hi CocMenuSel ctermfg=NONE ctermbg=22 cterm=NONE hi CocSearch ctermfg=222 ctermbg=NONE cterm=NONE else " Light background @@ -433,7 +456,7 @@ if s:t_Co >= 256 hi EndOfBuffer ctermfg=247 ctermbg=NONE cterm=NONE hi SpecialKey ctermfg=247 ctermbg=NONE cterm=NONE hi Pmenu ctermfg=NONE ctermbg=255 cterm=NONE - hi PmenuSel ctermfg=NONE ctermbg=151 cterm=NONE + hi PmenuSel ctermfg=NONE ctermbg=251 cterm=NONE hi PmenuThumb ctermfg=NONE ctermbg=243 cterm=NONE hi PmenuSbar ctermfg=NONE ctermbg=NONE cterm=NONE hi SignColumn ctermfg=NONE ctermbg=NONE cterm=NONE @@ -494,7 +517,6 @@ if s:t_Co >= 256 hi dirFilterMenuHistoryPath ctermfg=241 ctermbg=NONE cterm=NONE hi FilterMenuDirectorySubtle ctermfg=241 ctermbg=NONE cterm=NONE hi FilterMenuLineNr ctermfg=241 ctermbg=NONE cterm=NONE - hi CocMenuSel ctermfg=NONE ctermbg=151 cterm=NONE hi CocSearch ctermfg=88 ctermbg=NONE cterm=NONE endif unlet s:t_Co @@ -504,8 +526,8 @@ endif if s:t_Co >= 16 if &background ==# 'dark' hi Normal ctermfg=grey ctermbg=black cterm=NONE - hi Statusline ctermfg=black ctermbg=grey cterm=bold - hi StatuslineNC ctermfg=black ctermbg=darkgrey cterm=NONE + hi Statusline ctermfg=grey ctermbg=black cterm=bold,reverse + hi StatuslineNC ctermfg=darkgrey ctermbg=black cterm=reverse hi VertSplit ctermfg=darkgrey ctermbg=darkgrey cterm=NONE hi TabLine ctermfg=black ctermbg=grey cterm=NONE hi TabLineFill ctermfg=NONE ctermbg=darkgrey cterm=NONE @@ -520,7 +542,7 @@ if s:t_Co >= 16 hi EndOfBuffer ctermfg=grey ctermbg=NONE cterm=NONE hi SpecialKey ctermfg=grey ctermbg=NONE cterm=NONE hi Pmenu ctermfg=black ctermbg=darkgrey cterm=NONE - hi PmenuSel ctermfg=black ctermbg=darkgreen cterm=NONE + hi PmenuSel ctermfg=black ctermbg=darkcyan cterm=NONE hi PmenuThumb ctermfg=NONE ctermbg=grey cterm=NONE hi PmenuSbar ctermfg=NONE ctermbg=NONE cterm=NONE hi SignColumn ctermfg=NONE ctermbg=NONE cterm=NONE @@ -567,6 +589,20 @@ if s:t_Co >= 16 hi diffAdded ctermfg=green ctermbg=NONE cterm=NONE hi diffRemoved ctermfg=darkred ctermbg=NONE cterm=NONE hi diffSubname ctermfg=magenta ctermbg=NONE cterm=NONE + hi dirType ctermfg=darkmagenta ctermbg=NONE cterm=NONE + hi dirPermissionUser ctermfg=darkgreen ctermbg=NONE cterm=NONE + hi dirPermissionGroup ctermfg=darkyellow ctermbg=NONE cterm=NONE + hi dirPermissionOther ctermfg=darkcyan ctermbg=NONE cterm=NONE + hi dirOwner ctermfg=darkgrey ctermbg=NONE cterm=NONE + hi dirGroup ctermfg=darkgrey ctermbg=NONE cterm=NONE + hi dirTime ctermfg=darkgrey ctermbg=NONE cterm=NONE + hi dirSize ctermfg=yellow ctermbg=NONE cterm=NONE + hi dirSizeMod ctermfg=darkmagenta ctermbg=NONE cterm=NONE + hi FilterMenuDirectorySubtle ctermfg=grey ctermbg=NONE cterm=NONE + hi dirFilterMenuBookmarkPath ctermfg=grey ctermbg=NONE cterm=NONE + hi dirFilterMenuHistoryPath ctermfg=grey ctermbg=NONE cterm=NONE + hi FilterMenuLineNr ctermfg=grey ctermbg=NONE cterm=NONE + hi CocSearch ctermfg=yellow ctermbg=NONE cterm=NONE else " Light background hi Normal ctermfg=black ctermbg=white cterm=NONE @@ -586,7 +622,7 @@ if s:t_Co >= 16 hi EndOfBuffer ctermfg=darkgrey ctermbg=NONE cterm=NONE hi SpecialKey ctermfg=darkgrey ctermbg=NONE cterm=NONE hi Pmenu ctermfg=black ctermbg=grey cterm=NONE - hi PmenuSel ctermfg=black ctermbg=darkgreen cterm=NONE + hi PmenuSel ctermfg=black ctermbg=darkcyan cterm=NONE hi PmenuThumb ctermfg=NONE ctermbg=darkgrey cterm=NONE hi PmenuSbar ctermfg=NONE ctermbg=NONE cterm=NONE hi SignColumn ctermfg=NONE ctermbg=NONE cterm=NONE @@ -633,6 +669,21 @@ if s:t_Co >= 16 hi diffAdded ctermfg=darkgreen ctermbg=NONE cterm=NONE hi diffRemoved ctermfg=red ctermbg=NONE cterm=NONE hi diffSubname ctermfg=darkmagenta ctermbg=NONE cterm=NONE + hi dirType ctermfg=darkcyan ctermbg=NONE cterm=NONE + hi dirPermissionUser ctermfg=darkyellow ctermbg=NONE cterm=NONE + hi dirPermissionGroup ctermfg=darkgreen ctermbg=NONE cterm=NONE + hi dirPermissionOther ctermfg=darkmagenta ctermbg=NONE cterm=NONE + hi dirOwner ctermfg=grey ctermbg=NONE cterm=NONE + hi dirGroup ctermfg=grey ctermbg=NONE cterm=NONE + hi dirTime ctermfg=grey ctermbg=NONE cterm=NONE + hi dirSize ctermfg=darkred ctermbg=NONE cterm=NONE + hi dirSizeMod ctermfg=darkcyan ctermbg=NONE cterm=NONE + hi dirLink ctermfg=darkgreen ctermbg=NONE cterm=bold + hi dirFilterMenuBookmarkPath ctermfg=darkgrey ctermbg=NONE cterm=NONE + hi dirFilterMenuHistoryPath ctermfg=darkgrey ctermbg=NONE cterm=NONE + hi FilterMenuDirectorySubtle ctermfg=darkgrey ctermbg=NONE cterm=NONE + hi FilterMenuLineNr ctermfg=darkgrey ctermbg=NONE cterm=NONE + hi CocSearch ctermfg=darkred ctermbg=NONE cterm=NONE endif unlet s:t_Co finish @@ -659,7 +710,7 @@ if s:t_Co >= 8 hi Pmenu ctermfg=black ctermbg=grey cterm=NONE hi PmenuThumb ctermfg=NONE ctermbg=darkgreen cterm=NONE hi PmenuSbar ctermfg=NONE ctermbg=NONE cterm=NONE - hi PmenuSel ctermfg=black ctermbg=darkgreen cterm=NONE + hi PmenuSel ctermfg=black ctermbg=darkcyan cterm=NONE hi SignColumn ctermfg=NONE ctermbg=NONE cterm=NONE hi Error ctermfg=grey ctermbg=darkred cterm=NONE hi ErrorMsg ctermfg=grey ctermbg=darkred cterm=NONE @@ -688,7 +739,7 @@ if s:t_Co >= 8 hi Comment ctermfg=darkblue ctermbg=NONE cterm=NONE hi Constant ctermfg=darkred ctermbg=NONE cterm=NONE hi Identifier ctermfg=NONE ctermbg=NONE cterm=NONE - hi Statement ctermfg=black ctermbg=NONE cterm=bold + hi Statement ctermfg=grey ctermbg=NONE cterm=bold hi Type ctermfg=darkgreen ctermbg=NONE cterm=bold hi PreProc ctermfg=darkyellow ctermbg=NONE cterm=NONE hi Special ctermfg=darkcyan ctermbg=NONE cterm=NONE @@ -722,7 +773,7 @@ if s:t_Co >= 8 hi Pmenu ctermfg=grey ctermbg=black cterm=NONE hi PmenuThumb ctermfg=NONE ctermbg=darkgreen cterm=NONE hi PmenuSbar ctermfg=NONE ctermbg=NONE cterm=NONE - hi PmenuSel ctermfg=black ctermbg=darkgreen cterm=NONE + hi PmenuSel ctermfg=black ctermbg=darkcyan cterm=NONE hi SignColumn ctermfg=NONE ctermbg=NONE cterm=NONE hi Error ctermfg=grey ctermbg=darkred cterm=NONE hi ErrorMsg ctermfg=grey ctermbg=darkred cterm=NONE @@ -864,7 +915,7 @@ endif " Color: colorlC #FF5FFF 207 magenta " Color: colorV #005F87 24 darkblue " Color: colorMP #C5E7C5 30 darkcyan -" Color: colorPMenuSel #005F00 22 darkgreen +" Color: colorPMenuSel #444444 238 darkcyan " Color: colorDim #878787 102 grey " Color: diffAdd #AF87AF 139 darkmagenta " Color: diffDelete #D78787 174 darkred @@ -898,7 +949,7 @@ endif " Color: colorlC #FF00FF 201 magenta " Color: colorV #5F87AF 67 darkblue " Color: colorMP #C5E7C5 30 darkcyan -" Color: colorPMenuSel #AFD7AF 151 darkgreen +" Color: colorPMenuSel #C6C6C6 251 darkcyan " Color: colorDim #626262 241 darkgrey " Color: diffAdd #D7AFD7 182 darkmagenta " Color: diffDelete #870000 88 darkred diff --git a/runtime/colors/morning.vim b/runtime/colors/morning.vim index 5e6e0727da..f1ac73fe3d 100644 --- a/runtime/colors/morning.vim +++ b/runtime/colors/morning.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Bram Moolenaar " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:41 MSK +" Last Updated: Fri 02 Sep 2022 09:46:24 MSK " Generated by Colortemplate v2.2.0 @@ -26,6 +26,8 @@ hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine hi! link StatuslineTerm Statusline hi! link StatuslineTermNC StatuslineNC +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#000000 guibg=#e4e4e4 gui=NONE cterm=NONE hi EndOfBuffer guifg=#0000ff guibg=#cccccc gui=bold cterm=bold hi Folded guifg=#00008b guibg=#d3d3d3 gui=NONE cterm=NONE @@ -96,6 +98,8 @@ if s:t_Co >= 256 hi! link CursorLineSign CursorLine hi! link StatuslineTerm Statusline hi! link StatuslineTermNC StatuslineNC + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=16 ctermbg=254 cterm=NONE hi EndOfBuffer ctermfg=21 ctermbg=252 cterm=bold hi Folded ctermfg=18 ctermbg=252 cterm=NONE diff --git a/runtime/colors/murphy.vim b/runtime/colors/murphy.vim index c028c23eda..3dcff2c3c0 100644 --- a/runtime/colors/murphy.vim +++ b/runtime/colors/murphy.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Ron Aaron . " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:41 MSK +" Last Updated: Fri 02 Sep 2022 09:47:20 MSK " Generated by Colortemplate v2.2.0 @@ -26,6 +26,8 @@ hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine hi! link StatusLineTerm StatusLine hi! link StatusLineTermNC StatusLineNC +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#87ff87 guibg=#000000 gui=NONE cterm=NONE hi EndOfBuffer guifg=#0000ff guibg=#000000 gui=NONE cterm=NONE hi StatusLine guifg=#ffffff guibg=#00008b gui=NONE cterm=NONE @@ -96,6 +98,8 @@ if s:t_Co >= 256 hi! link CursorLineSign CursorLine hi! link StatusLineTerm StatusLine hi! link StatusLineTermNC StatusLineNC + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=120 ctermbg=16 cterm=NONE hi EndOfBuffer ctermfg=21 ctermbg=16 cterm=NONE hi StatusLine ctermfg=231 ctermbg=18 cterm=NONE diff --git a/runtime/colors/pablo.vim b/runtime/colors/pablo.vim index 948997340b..ece50e6b82 100644 --- a/runtime/colors/pablo.vim +++ b/runtime/colors/pablo.vim @@ -3,7 +3,7 @@ " Maintainer: Original maintainerRon Aaron " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:42 MSK +" Last Updated: Sun 04 Sep 2022 09:53:40 MSK " Generated by Colortemplate v2.2.0 @@ -17,13 +17,15 @@ let s:t_Co = exists('&t_Co') && !has('gui_running') ? (&t_Co ?? 0) : -1 if (has('termguicolors') && &termguicolors) || has('gui_running') let g:terminal_ansi_colors = ['#000000', '#cd0000', '#00cd00', '#cdcd00', '#0000ee', '#cd00cd', '#00cdcd', '#e5e5e5', '#7f7f7f', '#ff0000', '#00ff00', '#ffff00', '#5c5cff', '#ff00ff', '#00ffff', '#ffffff'] endif -hi Normal guifg=#ffffff guibg=#000000 gui=NONE cterm=NONE hi! link Terminal Normal hi! link StatusLineTerm StatusLine hi! link StatusLineTermNC StatusLineNC hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo +hi Normal guifg=#ffffff guibg=#000000 gui=NONE cterm=NONE hi Comment guifg=#808080 guibg=NONE gui=NONE cterm=NONE hi Constant guifg=#00ffff guibg=NONE gui=NONE cterm=NONE hi Identifier guifg=#00c0c0 guibg=NONE gui=NONE cterm=NONE @@ -88,13 +90,15 @@ hi DiffText guifg=#000000 guibg=#c6c6c6 gui=NONE cterm=NONE hi DiffDelete guifg=#ffffff guibg=#af5faf gui=NONE cterm=NONE if s:t_Co >= 256 - hi Normal ctermfg=231 ctermbg=16 cterm=NONE hi! link Terminal Normal hi! link StatusLineTerm StatusLine hi! link StatusLineTermNC StatusLineNC hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo + hi Normal ctermfg=231 ctermbg=16 cterm=NONE hi Comment ctermfg=244 ctermbg=NONE cterm=NONE hi Constant ctermfg=51 ctermbg=NONE cterm=NONE hi Identifier ctermfg=37 ctermbg=NONE cterm=NONE @@ -117,7 +121,7 @@ if s:t_Co >= 256 hi NonText ctermfg=63 ctermbg=NONE cterm=bold hi EndOfBuffer ctermfg=63 ctermbg=NONE cterm=bold hi ErrorMsg ctermfg=231 ctermbg=160 cterm=NONE - hi WarningMsg ctermfg=224 ctermbg=NONE cterm=NONE + hi WarningMsg ctermfg=196 ctermbg=NONE cterm=NONE hi SignColumn ctermfg=51 ctermbg=248 cterm=NONE hi ColorColumn ctermfg=NONE ctermbg=239 cterm=NONE hi FoldColumn ctermfg=102 ctermbg=236 cterm=NONE @@ -163,12 +167,6 @@ endif if s:t_Co >= 16 hi Normal ctermfg=white ctermbg=black cterm=NONE - hi! link Terminal Normal - hi! link StatusLineTerm StatusLine - hi! link StatusLineTermNC StatusLineNC - hi! link CurSearch Search - hi! link CursorLineFold CursorLine - hi! link CursorLineSign CursorLine hi Comment ctermfg=darkgrey ctermbg=NONE cterm=NONE hi Constant ctermfg=cyan ctermbg=NONE cterm=NONE hi Identifier ctermfg=darkcyan ctermbg=NONE cterm=NONE @@ -191,7 +189,7 @@ if s:t_Co >= 16 hi NonText ctermfg=blue ctermbg=NONE cterm=bold hi EndOfBuffer ctermfg=blue ctermbg=NONE cterm=bold hi ErrorMsg ctermfg=white ctermbg=darkred cterm=NONE - hi WarningMsg ctermfg=darkred ctermbg=NONE cterm=NONE + hi WarningMsg ctermfg=red ctermbg=NONE cterm=NONE hi SignColumn ctermfg=cyan ctermbg=black cterm=NONE hi ColorColumn ctermfg=white ctermbg=darkgrey cterm=NONE hi FoldColumn ctermfg=NONE ctermbg=NONE cterm=NONE @@ -405,7 +403,7 @@ endif " Color: SpecialKey #00ffff 81 cyan " Color: StatusLineTerm #90ee90 121 darkgreen " Color: Title #ff00ff 225 magenta -" Color: WarningMsg #ff0000 224 darkred +" Color: WarningMsg #ff0000 196 red " Color: ToolbarLine #7f7f7f 242 darkgrey " Color: ToolbarButton #d3d3d3 254 grey " Color: Underlined #80a0ff 111 darkgreen diff --git a/runtime/colors/peachpuff.vim b/runtime/colors/peachpuff.vim index 1668b6811a..0622ce6f87 100644 --- a/runtime/colors/peachpuff.vim +++ b/runtime/colors/peachpuff.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer David Ne\v{c}as (Yeti) " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:42 MSK +" Last Updated: Fri 02 Sep 2022 09:50:02 MSK " Generated by Colortemplate v2.2.0 @@ -24,6 +24,8 @@ hi! link LineNrBelow LineNr hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#000000 guibg=#ffdab9 gui=NONE cterm=NONE hi Folded guifg=#000000 guibg=#e3c1a5 gui=NONE cterm=NONE hi CursorLine guifg=NONE guibg=#f5c195 gui=NONE cterm=NONE @@ -94,6 +96,8 @@ if s:t_Co >= 256 hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=16 ctermbg=223 cterm=NONE hi Folded ctermfg=16 ctermbg=252 cterm=NONE hi CursorLine ctermfg=NONE ctermbg=180 cterm=NONE diff --git a/runtime/colors/quiet.vim b/runtime/colors/quiet.vim index 6f5be5b349..fbe58b4124 100644 --- a/runtime/colors/quiet.vim +++ b/runtime/colors/quiet.vim @@ -4,7 +4,7 @@ " Maintainer: neutaaaaan " Website: https://github.com/vim/colorschemes " License: Vim License (see `:help license`)` -" Last Updated: Tue 23 Aug 2022 16:50:43 MSK +" Last Updated: Fri 02 Sep 2022 09:55:30 MSK " Generated by Colortemplate v2.2.0 @@ -16,6 +16,8 @@ let s:t_Co = exists('&t_Co') && !has('gui_running') ? (&t_Co ?? 0) : -1 hi! link Terminal Normal hi! link StatusLineTerm StatusLine hi! link StatusLineTermNC StatusLineNC +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi! link Boolean Constant hi! link Character Constant hi! link Conditional Statement diff --git a/runtime/colors/ron.vim b/runtime/colors/ron.vim index aeccfcedf2..a7302a44eb 100644 --- a/runtime/colors/ron.vim +++ b/runtime/colors/ron.vim @@ -3,7 +3,7 @@ " Maintainer: original maintainer Ron Aaron " Website: https://www.github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:45 MSK +" Last Updated: Fri 02 Sep 2022 09:50:56 MSK " Generated by Colortemplate v2.2.0 @@ -46,6 +46,8 @@ hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine hi! link LineNrAbove LineNr hi! link LineNrBelow LineNr +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo if (has('termguicolors') && &termguicolors) || has('gui_running') let g:terminal_ansi_colors = ['#000000', '#cd0000', '#00cd00', '#cdcd00', '#0000ee', '#cd00cd', '#00cdcd', '#e5e5e5', '#7f7f7f', '#ff0000', '#00ff00', '#ffff00', '#5c5cff', '#ff00ff', '#00ffff', '#ffffff'] diff --git a/runtime/colors/shine.vim b/runtime/colors/shine.vim index e74b0aed83..fe1ee15203 100644 --- a/runtime/colors/shine.vim +++ b/runtime/colors/shine.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer is Yasuhiro Matsumoto " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:46 MSK +" Last Updated: Fri 02 Sep 2022 09:51:42 MSK " Generated by Colortemplate v2.2.0 @@ -28,6 +28,8 @@ hi! link EndOfBuffer NonText hi! link ErrorMsg Error hi! link Tag Special hi! link Operator Statement +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#000000 guibg=#ffffff gui=NONE cterm=NONE hi Folded guifg=#00008b guibg=#dadada gui=NONE cterm=NONE hi CursorLine guifg=NONE guibg=#dadada gui=NONE cterm=NONE @@ -104,6 +106,8 @@ if s:t_Co >= 256 hi! link ErrorMsg Error hi! link Tag Special hi! link Operator Statement + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=16 ctermbg=231 cterm=NONE hi Folded ctermfg=18 ctermbg=253 cterm=NONE hi CursorLine ctermfg=NONE ctermbg=253 cterm=NONE diff --git a/runtime/colors/slate.vim b/runtime/colors/slate.vim index 584e4b52c5..8c43fb6ed6 100644 --- a/runtime/colors/slate.vim +++ b/runtime/colors/slate.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Ralph Amissah " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:46 MSK +" Last Updated: Fri 02 Sep 2022 09:52:25 MSK " Generated by Colortemplate v2.2.0 @@ -24,6 +24,8 @@ hi! link LineNrBelow LineNr hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#ffffff guibg=#262626 gui=NONE cterm=NONE hi EndOfBuffer guifg=#5f87d7 guibg=NONE gui=NONE cterm=NONE hi StatusLine guifg=#000000 guibg=#afaf87 gui=NONE cterm=NONE @@ -99,6 +101,8 @@ if s:t_Co >= 256 hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=231 ctermbg=235 cterm=NONE hi EndOfBuffer ctermfg=68 ctermbg=NONE cterm=NONE hi StatusLine ctermfg=16 ctermbg=144 cterm=NONE diff --git a/runtime/colors/torte.vim b/runtime/colors/torte.vim index 814e50db15..7ea5a69196 100644 --- a/runtime/colors/torte.vim +++ b/runtime/colors/torte.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Thorsten Maerz " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:47 MSK +" Last Updated: Fri 02 Sep 2022 09:53:21 MSK " Generated by Colortemplate v2.2.0 @@ -26,6 +26,8 @@ hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine hi! link StatusLineTerm StatusLine hi! link StatusLineTermNC StatusLineNC +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#cccccc guibg=#000000 gui=NONE cterm=NONE hi Comment guifg=#80a0ff guibg=NONE gui=NONE cterm=NONE hi Constant guifg=#ffa0a0 guibg=NONE gui=NONE cterm=NONE @@ -97,6 +99,8 @@ if s:t_Co >= 256 hi! link CursorLineSign CursorLine hi! link StatusLineTerm StatusLine hi! link StatusLineTermNC StatusLineNC + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=251 ctermbg=16 cterm=NONE hi Comment ctermfg=111 ctermbg=NONE cterm=NONE hi Constant ctermfg=217 ctermbg=NONE cterm=NONE diff --git a/runtime/colors/zellner.vim b/runtime/colors/zellner.vim index 191dc7ef4b..86340eb5b0 100644 --- a/runtime/colors/zellner.vim +++ b/runtime/colors/zellner.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Ron Aaron " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Tue 23 Aug 2022 16:50:48 MSK +" Last Updated: Fri 02 Sep 2022 09:54:15 MSK " Generated by Colortemplate v2.2.0 @@ -24,6 +24,8 @@ hi! link LineNrBelow LineNr hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine +hi! link MessageWindow Pmenu +hi! link PopupNotification Todo hi Normal guifg=#000000 guibg=#ffffff gui=NONE cterm=NONE hi Folded guifg=#00008b guibg=#d3d3d3 gui=NONE cterm=NONE hi CursorLine guifg=NONE guibg=#e5e5e5 gui=NONE cterm=NONE @@ -95,6 +97,8 @@ if s:t_Co >= 256 hi! link CurSearch Search hi! link CursorLineFold CursorLine hi! link CursorLineSign CursorLine + hi! link MessageWindow Pmenu + hi! link PopupNotification Todo hi Normal ctermfg=16 ctermbg=231 cterm=NONE hi Folded ctermfg=18 ctermbg=252 cterm=NONE hi CursorLine ctermfg=NONE ctermbg=254 cterm=NONE diff --git a/runtime/doc/Makefile b/runtime/doc/Makefile index b28d246757..674d0be8b6 100644 --- a/runtime/doc/Makefile +++ b/runtime/doc/Makefile @@ -116,6 +116,7 @@ DOCS = \ todo.txt \ uganda.txt \ undo.txt \ + userfunc.txt \ usr_01.txt \ usr_02.txt \ usr_03.txt \ @@ -266,6 +267,7 @@ HTMLS = \ todo.html \ uganda.html \ undo.html \ + userfunc.html \ usr_01.html \ usr_02.html \ usr_03.html \ diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 793dd3e49a..822f5409fc 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -642,6 +642,8 @@ CmdwinLeave Before leaving the command-line window. |cmdwin-char| *ColorScheme* ColorScheme After loading a color scheme. |:colorscheme| + Not triggered if the color scheme is not + found. The pattern is matched against the colorscheme name. can be used for the name of the actual file where this option was diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 29146dc649..1de0e40ad1 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1671,7 +1671,7 @@ complete_info([{what}]) *complete_info()* typed text only, or the last completion after no item is selected when using the or keys) - inserted Inserted string. [NOT IMPLEMENT YET] + inserted Inserted string. [NOT IMPLEMENTED YET] *complete_info_mode* mode values are: @@ -3038,10 +3038,10 @@ function({name} [, {arglist}] [, {dict}]) Funcref. The extra arguments are appended to the list of arguments. Example: > func Callback(arg1, arg2, name) - ... + "... let Func = function('Callback', ['one']) let Func2 = function(Func, ['two']) - ... + "... call Func2('name') < Invokes the function as with: > call Callback('one', 'two', 'name') @@ -3051,22 +3051,23 @@ function({name} [, {arglist}] [, {dict}]) function Callback() dict echo "called for " .. self.name endfunction - ... + "... let context = {"name": "example"} let Func = function('Callback', context) - ... + "... call Func() " will echo: called for example < The use of function() is not needed when there are no extra - arguments, these two are equivalent: > + arguments, these two are equivalent, if Callback() is defined + as context.Callback(): > let Func = function('Callback', context) let Func = context.Callback < The argument list and the Dictionary can be combined: > function Callback(arg1, count) dict - ... + "... let context = {"name": "example"} let Func = function('Callback', ['one'], context) - ... + "... call Func(500) < Invokes the function as with: > call context.Callback('one', 500) @@ -10448,34 +10449,43 @@ writefile({object}, {fname} [, {flags}]) When {object} is a |List| write it to file {fname}. Each list item is separated with a NL. Each list item must be a String or Number. - When {flags} contains "b" then binary mode is used: There will - not be a NL after the last list item. An empty item at the - end does cause the last line in the file to end in a NL. - - When {object} is a |Blob| write the bytes to file {fname} - unmodified. - - When {flags} contains "a" then append mode is used, lines are - appended to the file: > - :call writefile(["foo"], "event.log", "a") - :call writefile(["bar"], "event.log", "a") -< - When {flags} contains "s" then fsync() is called after writing - the file. This flushes the file to disk, if possible. This - takes more time but avoids losing the file if the system - crashes. - When {flags} does not contain "S" or "s" then fsync() is - called if the 'fsync' option is set. - When {flags} contains "S" then fsync() is not called, even - when 'fsync' is set. - All NL characters are replaced with a NUL character. Inserting CR characters needs to be done before passing {list} to writefile(). + + When {object} is a |Blob| write the bytes to file {fname} + unmodified, also when binary mode is not specified. + + {flags} must be a String. These characters are recognized: + + 'b' Binary mode is used: There will not be a NL after the + last list item. An empty item at the end does cause the + last line in the file to end in a NL. + + 'a' Append mode is used, lines are appended to the file: > + :call writefile(["foo"], "event.log", "a") + :call writefile(["bar"], "event.log", "a") +< + 'D' Delete the file when the current function ends. This + works like: > + :defer delete({fname}) +< Fails when not in a function. Also see |:defer|. + + 's' fsync() is called after writing the file. This flushes + the file to disk, if possible. This takes more time but + avoids losing the file if the system crashes. + + 'S' fsync() is not called, even when 'fsync' is set. + + When {flags} does not contain "S" or "s" then fsync() is + called if the 'fsync' option is set. + An existing file is overwritten, if possible. + When the write fails -1 is returned, otherwise 0. There is an error message if the file can't be created or when writing fails. + Also see |readfile()|. To copy a file byte for byte: > :let fl = readfile("foo", "b") diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index fb694f5520..647531a7da 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2641,447 +2641,12 @@ help file: |builtin-functions|. 5. Defining functions *user-functions* New functions can be defined. These can be called just like builtin -functions. The function executes a sequence of Ex commands. Normal mode -commands can be executed with the |:normal| command. +functions. The function takes arguments, executes a sequence of Ex commands +and can return a value. -This section is about the legacy functions. For the Vim9 functions, which -execute much faster, support type checking and more, see |vim9.txt|. - -The function name must start with an uppercase letter, to avoid confusion with -builtin functions. To prevent from using the same name in different scripts -avoid obvious, short names. A good habit is to start the function name with -the name of the script, e.g., "HTMLcolor()". - -In legacy script it is also possible to use curly braces, see -|curly-braces-names|. -The |autoload| facility is useful to define a function only when it's called. - - *local-function* -A function local to a legacy script must start with "s:". A local script -function can only be called from within the script and from functions, user -commands and autocommands defined in the script. It is also possible to call -the function from a mapping defined in the script, but then || must be -used instead of "s:" when the mapping is expanded outside of the script. -There are only script-local functions, no buffer-local or window-local -functions. - -In |Vim9| script functions are local to the script by default, prefix "g:" to -define a global function. - - *:fu* *:function* *E128* *E129* *E123* *E454* -:fu[nction] List all functions and their arguments. - -:fu[nction] {name} List function {name}. - {name} can also be a |Dictionary| entry that is a - |Funcref|: > - :function dict.init - -:fu[nction] /{pattern} List functions with a name matching {pattern}. - Example that lists all functions ending with "File": > - :function /File$ -< - *:function-verbose* -When 'verbose' is non-zero, listing a function will also display where it was -last defined. Example: > - - :verbose function SetFileTypeSH - function SetFileTypeSH(name) - Last set from /usr/share/vim/vim-7.0/filetype.vim -< -See |:verbose-cmd| for more information. - - *E124* *E125* *E853* *E884* -:fu[nction][!] {name}([arguments]) [range] [abort] [dict] [closure] - Define a new function by the name {name}. The body of - the function follows in the next lines, until the - matching |:endfunction|. - *E1267* - The name must be made of alphanumeric characters and - '_', and must start with a capital or "s:" (see - above). Note that using "b:" or "g:" is not allowed. - (since patch 7.4.260 E884 is given if the function - name has a colon in the name, e.g. for "foo:bar()". - Before that patch no error was given). - - {name} can also be a |Dictionary| entry that is a - |Funcref|: > - :function dict.init(arg) -< "dict" must be an existing dictionary. The entry - "init" is added if it didn't exist yet. Otherwise [!] - is required to overwrite an existing function. The - result is a |Funcref| to a numbered function. The - function can only be used with a |Funcref| and will be - deleted if there are no more references to it. - *E127* *E122* - When a function by this name already exists and [!] is - not used an error message is given. There is one - exception: When sourcing a script again, a function - that was previously defined in that script will be - silently replaced. - When [!] is used, an existing function is silently - replaced. Unless it is currently being executed, that - is an error. - NOTE: Use ! wisely. If used without care it can cause - an existing function to be replaced unexpectedly, - which is hard to debug. - NOTE: In Vim9 script script-local functions cannot be - deleted or redefined. - - For the {arguments} see |function-argument|. - - *:func-range* *a:firstline* *a:lastline* - When the [range] argument is added, the function is - expected to take care of a range itself. The range is - passed as "a:firstline" and "a:lastline". If [range] - is excluded, ":{range}call" will call the function for - each line in the range, with the cursor on the start - of each line. See |function-range-example|. - The cursor is still moved to the first line of the - range, as is the case with all Ex commands. - *:func-abort* - When the [abort] argument is added, the function will - abort as soon as an error is detected. - *:func-dict* - When the [dict] argument is added, the function must - be invoked through an entry in a |Dictionary|. The - local variable "self" will then be set to the - dictionary. See |Dictionary-function|. - *:func-closure* *E932* - When the [closure] argument is added, the function - can access variables and arguments from the outer - scope. This is usually called a closure. In this - example Bar() uses "x" from the scope of Foo(). It - remains referenced even after Foo() returns: > - :function! Foo() - : let x = 0 - : function! Bar() closure - : let x += 1 - : return x - : endfunction - : return funcref('Bar') - :endfunction - - :let F = Foo() - :echo F() -< 1 > - :echo F() -< 2 > - :echo F() -< 3 - - *function-search-undo* - The last used search pattern and the redo command "." - will not be changed by the function. This also - implies that the effect of |:nohlsearch| is undone - when the function returns. - - *:endf* *:endfunction* *E126* *E193* *W22* *E1151* -:endf[unction] [argument] - The end of a function definition. Best is to put it - on a line by its own, without [argument]. - - [argument] can be: - | command command to execute next - \n command command to execute next - " comment always ignored - anything else ignored, warning given when - 'verbose' is non-zero - The support for a following command was added in Vim - 8.0.0654, before that any argument was silently - ignored. - - To be able to define a function inside an `:execute` - command, use line breaks instead of |:bar|: > - :exe "func Foo()\necho 'foo'\nendfunc" -< - *:delf* *:delfunction* *E131* *E933* *E1084* -:delf[unction][!] {name} - Delete function {name}. - {name} can also be a |Dictionary| entry that is a - |Funcref|: > - :delfunc dict.init -< This will remove the "init" entry from "dict". The - function is deleted if there are no more references to - it. - With the ! there is no error if the function does not - exist. - *:retu* *:return* *E133* -:retu[rn] [expr] Return from a function. When "[expr]" is given, it is - evaluated and returned as the result of the function. - If "[expr]" is not given, the number 0 is returned. - When a function ends without an explicit ":return", - the number 0 is returned. - In a :def function *E1095* is given if unreachable - code follows after the `:return`. - In legacy script there is no check for unreachable - lines, thus there is no warning if commands follow - `:return`. - - If the ":return" is used after a |:try| but before the - matching |:finally| (if present), the commands - following the ":finally" up to the matching |:endtry| - are executed first. This process applies to all - nested ":try"s inside the function. The function - returns at the outermost ":endtry". - - *function-argument* *a:var* -An argument can be defined by giving its name. In the function this can then -be used as "a:name" ("a:" for argument). - *a:0* *a:1* *a:000* *E740* *...* -Up to 20 arguments can be given, separated by commas. After the named -arguments an argument "..." can be specified, which means that more arguments -may optionally be following. In the function the extra arguments can be used -as "a:1", "a:2", etc. "a:0" is set to the number of extra arguments (which -can be 0). "a:000" is set to a |List| that contains these arguments. Note -that "a:1" is the same as "a:000[0]". - *E742* *E1090* -The a: scope and the variables in it cannot be changed, they are fixed. -However, if a composite type is used, such as |List| or |Dictionary| , you can -change their contents. Thus you can pass a |List| to a function and have the -function add an item to it. If you want to make sure the function cannot -change a |List| or |Dictionary| use |:lockvar|. - -It is also possible to define a function without any arguments. You must -still supply the () then. - -It is allowed to define another function inside a function body. - - *optional-function-argument* -You can provide default values for positional named arguments. This makes -them optional for function calls. When a positional argument is not -specified at a call, the default expression is used to initialize it. -This only works for functions declared with `:function` or `:def`, not for -lambda expressions |expr-lambda|. - -Example: > - function Something(key, value = 10) - echo a:key .. ": " .. a:value - endfunction - call Something('empty') "empty: 10" - call Something('key', 20) "key: 20" - -The argument default expressions are evaluated at the time of the function -call, not definition. Thus it is possible to use an expression which is -invalid the moment the function is defined. The expressions are also only -evaluated when arguments are not specified during a call. - *none-function_argument* -You can pass |v:none| to use the default expression. Note that this means you -cannot pass v:none as an ordinary value when an argument has a default -expression. - -Example: > - function Something(a = 10, b = 20, c = 30) - endfunction - call Something(1, v:none, 3) " b = 20 -< - *E989* -Optional arguments with default expressions must occur after any mandatory -arguments. You can use "..." after all optional named arguments. - -It is possible for later argument defaults to refer to prior arguments, -but not the other way around. They must be prefixed with "a:", as with all -arguments. - -Example that works: > - :function Okay(mandatory, optional = a:mandatory) - :endfunction -Example that does NOT work: > - :function NoGood(first = a:second, second = 10) - :endfunction -< -When not using "...", the number of arguments in a function call must be at -least equal to the number of mandatory named arguments. When using "...", the -number of arguments may be larger than the total of mandatory and optional -arguments. - - *local-variables* -Inside a function local variables can be used. These will disappear when the -function returns. Global variables need to be accessed with "g:". - -Example: > - :function Table(title, ...) - : echohl Title - : echo a:title - : echohl None - : echo a:0 .. " items:" - : for s in a:000 - : echon ' ' .. s - : endfor - :endfunction - -This function can then be called with: > - call Table("Table", "line1", "line2") - call Table("Empty Table") - -To return more than one value, return a |List|: > - :function Compute(n1, n2) - : if a:n2 == 0 - : return ["fail", 0] - : endif - : return ["ok", a:n1 / a:n2] - :endfunction - -This function can then be called with: > - :let [success, div] = Compute(102, 6) - :if success == "ok" - : echo div - :endif -< - *:cal* *:call* *E107* -:[range]cal[l] {name}([arguments]) - Call a function. The name of the function and its arguments - are as specified with `:function`. Up to 20 arguments can be - used. The returned value is discarded. - In |Vim9| script using `:call` is optional, these two lines do - the same thing: > - call SomeFunc(arg) - SomeFunc(arg) -< Without a range and for functions that accept a range, the - function is called once. When a range is given the cursor is - positioned at the start of the first line before executing the - function. - When a range is given and the function doesn't handle it - itself, the function is executed for each line in the range, - with the cursor in the first column of that line. The cursor - is left at the last line (possibly moved by the last function - call). The arguments are re-evaluated for each line. Thus - this works: - *function-range-example* > - :function Mynumber(arg) - : echo line(".") .. " " .. a:arg - :endfunction - :1,5call Mynumber(getline(".")) -< - The "a:firstline" and "a:lastline" are defined anyway, they - can be used to do something different at the start or end of - the range. - - Example of a function that handles the range itself: > - - :function Cont() range - : execute (a:firstline + 1) .. "," .. a:lastline .. 's/^/\t\\ ' - :endfunction - :4,8call Cont() -< - This function inserts the continuation character "\" in front - of all the lines in the range, except the first one. - - When the function returns a composite value it can be further - dereferenced, but the range will not be used then. Example: > - :4,8call GetDict().method() -< Here GetDict() gets the range but method() does not. - - *E117* -When a function cannot be found the error "E117: Unknown function" will be -given. If the function was using an autoload path or an autoload import and -the script is a |Vim9| script, this may also be caused by the function not -being exported. - - *E132* -The recursiveness of user functions is restricted with the |'maxfuncdepth'| -option. - -It is also possible to use `:eval`. It does not support a range, but does -allow for method chaining, e.g.: > - eval GetList()->Filter()->append('$') - -A function can also be called as part of evaluating an expression or when it -is used as a method: > - let x = GetList() - let y = GetList()->Filter() - - -AUTOMATICALLY LOADING FUNCTIONS ~ - *autoload-functions* -When using many or large functions, it's possible to automatically define them -only when they are used. There are two methods: with an autocommand and with -the "autoload" directory in 'runtimepath'. - - -Using an autocommand ~ - -This is introduced in the user manual, section |51.4|. - -The autocommand is useful if you have a plugin that is a long Vim script file. -You can define the autocommand and quickly quit the script with `:finish`. -That makes Vim startup faster. The autocommand should then load the same file -again, setting a variable to skip the `:finish` command. - -Use the FuncUndefined autocommand event with a pattern that matches the -function(s) to be defined. Example: > - - :au FuncUndefined BufNet* source ~/vim/bufnetfuncs.vim - -The file "~/vim/bufnetfuncs.vim" should then define functions that start with -"BufNet". Also see |FuncUndefined|. - - -Using an autoload script ~ - *autoload* *E746* -This is introduced in the user manual, section |52.2|. - -Using a script in the "autoload" directory is simpler, but requires using -exactly the right file name. A function that can be autoloaded has a name -like this: > - - :call filename#funcname() - -These functions are always global, in Vim9 script "g:" needs to be used: > - :call g:filename#funcname() - -When such a function is called, and it is not defined yet, Vim will search the -"autoload" directories in 'runtimepath' for a script file called -"filename.vim". For example "~/.vim/autoload/filename.vim". That file should -then define the function like this: > - - function filename#funcname() - echo "Done!" - endfunction - -The file name and the name used before the # in the function must match -exactly, and the defined function must have the name exactly as it will be -called. In Vim9 script the "g:" prefix must be used: > - function g:filename#funcname() - -or for a compiled function: > - def g:filename#funcname() - -It is possible to use subdirectories. Every # in the function name works like -a path separator. Thus when calling a function: > - - :call foo#bar#func() - -Vim will look for the file "autoload/foo/bar.vim" in 'runtimepath'. - -This also works when reading a variable that has not been set yet: > - - :let l = foo#bar#lvar - -However, when the autoload script was already loaded it won't be loaded again -for an unknown variable. - -When assigning a value to such a variable nothing special happens. This can -be used to pass settings to the autoload script before it's loaded: > - - :let foo#bar#toggle = 1 - :call foo#bar#func() - -Note that when you make a mistake and call a function that is supposed to be -defined in an autoload script, but the script doesn't actually define the -function, you will get an error message for the missing function. If you fix -the autoload script it won't be automatically loaded again. Either restart -Vim or manually source the script. - -Also note that if you have two script files, and one calls a function in the -other and vice versa, before the used function is defined, it won't work. -Avoid using the autoload functionality at the toplevel. - -In |Vim9| script you will get error *E1263* if you define a function with -a "#" character in the name. You should use a name without "#" and use -`:export`. - -Hint: If you distribute a bunch of scripts you can pack them together with the -|vimball| utility. Also read the user manual |distribute-script|. +You can find most information about defining functions in |userfunc.txt|. +For Vim9 functions, which execute much faster, support type checking and more, +see |vim9.txt|. ============================================================================== 6. Curly braces names *curly-braces-names* diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt index 8633b72edb..e9303cd326 100644 --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -141,6 +141,7 @@ Advanced editing ~ |autocmd.txt| automatically executing commands on an event |eval.txt| expression evaluation, conditional commands |builtin.txt| builtin functions +|userfunc.txt| defining user functions |channel.txt| Jobs, Channels, inter-process communication |fold.txt| hide (fold) ranges of lines diff --git a/runtime/doc/tags b/runtime/doc/tags index 1f49245b83..b814dc448b 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -1605,7 +1605,7 @@ $quote eval.txt /*$quote* -xrm gui_x11.txt /*-xrm* -y starting.txt /*-y* . repeat.txt /*.* -... eval.txt /*...* +... userfunc.txt /*...* .Xdefaults gui_x11.txt /*.Xdefaults* .aff spell.txt /*.aff* .dic spell.txt /*.dic* @@ -2283,8 +2283,8 @@ $quote eval.txt /*$quote* :caddfile quickfix.txt /*:caddfile* :caf quickfix.txt /*:caf* :cafter quickfix.txt /*:cafter* -:cal eval.txt /*:cal* -:call eval.txt /*:call* +:cal userfunc.txt /*:cal* +:call userfunc.txt /*:call* :cat eval.txt /*:cat* :catch eval.txt /*:catch* :cb quickfix.txt /*:cb* @@ -2428,13 +2428,14 @@ $quote eval.txt /*$quote* :def vim9.txt /*:def* :defc vim9.txt /*:defc* :defcompile vim9.txt /*:defcompile* +:defer userfunc.txt /*:defer* :del change.txt /*:del* :delc map.txt /*:delc* :delcommand map.txt /*:delcommand* :delcr todo.txt /*:delcr* :delete change.txt /*:delete* -:delf eval.txt /*:delf* -:delfunction eval.txt /*:delfunction* +:delf userfunc.txt /*:delf* +:delfunction userfunc.txt /*:delfunction* :delm motion.txt /*:delm* :delmarks motion.txt /*:delmarks* :di change.txt /*:di* @@ -2511,10 +2512,10 @@ $quote eval.txt /*$quote* :endclass vim9.txt /*:endclass* :enddef vim9.txt /*:enddef* :endenum vim9.txt /*:endenum* -:endf eval.txt /*:endf* +:endf userfunc.txt /*:endf* :endfo eval.txt /*:endfo* :endfor eval.txt /*:endfor* -:endfunction eval.txt /*:endfunction* +:endfunction userfunc.txt /*:endfunction* :endif eval.txt /*:endif* :endinterface vim9.txt /*:endinterface* :endt eval.txt /*:endt* @@ -2576,13 +2577,13 @@ $quote eval.txt /*$quote* :foldo fold.txt /*:foldo* :foldopen fold.txt /*:foldopen* :for eval.txt /*:for* -:fu eval.txt /*:fu* -:func-abort eval.txt /*:func-abort* -:func-closure eval.txt /*:func-closure* -:func-dict eval.txt /*:func-dict* -:func-range eval.txt /*:func-range* -:function eval.txt /*:function* -:function-verbose eval.txt /*:function-verbose* +:fu userfunc.txt /*:fu* +:func-abort userfunc.txt /*:func-abort* +:func-closure userfunc.txt /*:func-closure* +:func-dict userfunc.txt /*:func-dict* +:func-range userfunc.txt /*:func-range* +:function userfunc.txt /*:function* +:function-verbose userfunc.txt /*:function-verbose* :g repeat.txt /*:g* :global repeat.txt /*:global* :go motion.txt /*:go* @@ -2622,6 +2623,8 @@ $quote eval.txt /*$quote* :his cmdline.txt /*:his* :history cmdline.txt /*:history* :history-indexing cmdline.txt /*:history-indexing* +:hor windows.txt /*:hor* +:horizontal windows.txt /*:horizontal* :i insert.txt /*:i* :ia map.txt /*:ia* :iabbrev map.txt /*:iabbrev* @@ -3076,8 +3079,8 @@ $quote eval.txt /*$quote* :ret change.txt /*:ret* :retab change.txt /*:retab* :retab! change.txt /*:retab!* -:retu eval.txt /*:retu* -:return eval.txt /*:return* +:retu userfunc.txt /*:retu* +:return userfunc.txt /*:return* :rew editing.txt /*:rew* :rewind editing.txt /*:rewind* :ri change.txt /*:ri* @@ -4132,7 +4135,7 @@ E1066 vim9.txt /*E1066* E1067 eval.txt /*E1067* E1068 vim9.txt /*E1068* E1069 vim9.txt /*E1069* -E107 eval.txt /*E107* +E107 userfunc.txt /*E107* E1071 vim9.txt /*E1071* E1072 eval.txt /*E1072* E1073 vim9.txt /*E1073* @@ -4147,18 +4150,18 @@ E1080 vim9.txt /*E1080* E1081 eval.txt /*E1081* E1082 vim9.txt /*E1082* E1083 editing.txt /*E1083* -E1084 eval.txt /*E1084* +E1084 userfunc.txt /*E1084* E1085 eval.txt /*E1085* E1087 vim9.txt /*E1087* E1088 vim9.txt /*E1088* E1089 eval.txt /*E1089* E109 eval.txt /*E109* -E1090 eval.txt /*E1090* +E1090 userfunc.txt /*E1090* E1091 vim9.txt /*E1091* E1092 various.txt /*E1092* E1093 eval.txt /*E1093* E1094 vim9.txt /*E1094* -E1095 eval.txt /*E1095* +E1095 userfunc.txt /*E1095* E1096 vim9.txt /*E1096* E1097 vim9.txt /*E1097* E1098 eval.txt /*E1098* @@ -4221,7 +4224,7 @@ E1148 eval.txt /*E1148* E1149 vim9.txt /*E1149* E115 eval.txt /*E115* E1150 vim9.txt /*E1150* -E1151 eval.txt /*E1151* +E1151 userfunc.txt /*E1151* E1152 vim9.txt /*E1152* E1153 eval.txt /*E1153* E1154 eval.txt /*E1154* @@ -4241,7 +4244,7 @@ E1166 eval.txt /*E1166* E1167 vim9.txt /*E1167* E1168 vim9.txt /*E1168* E1169 eval.txt /*E1169* -E117 eval.txt /*E117* +E117 userfunc.txt /*E117* E1170 vim9.txt /*E1170* E1171 vim9.txt /*E1171* E1172 vim9.txt /*E1172* @@ -4297,7 +4300,7 @@ E1216 builtin.txt /*E1216* E1217 vim9.txt /*E1217* E1218 vim9.txt /*E1218* E1219 vim9.txt /*E1219* -E122 eval.txt /*E122* +E122 userfunc.txt /*E122* E1220 vim9.txt /*E1220* E1221 vim9.txt /*E1221* E1222 vim9.txt /*E1222* @@ -4308,7 +4311,7 @@ E1226 vim9.txt /*E1226* E1227 vim9.txt /*E1227* E1228 vim9.txt /*E1228* E1229 eval.txt /*E1229* -E123 eval.txt /*E123* +E123 userfunc.txt /*E123* E1230 options.txt /*E1230* E1231 map.txt /*E1231* E1232 builtin.txt /*E1232* @@ -4318,7 +4321,7 @@ E1236 vim9.txt /*E1236* E1237 map.txt /*E1237* E1238 vim9.txt /*E1238* E1239 builtin.txt /*E1239* -E124 eval.txt /*E124* +E124 userfunc.txt /*E124* E1240 change.txt /*E1240* E1241 change.txt /*E1241* E1242 change.txt /*E1242* @@ -4329,7 +4332,7 @@ E1246 eval.txt /*E1246* E1247 cmdline.txt /*E1247* E1248 vim9.txt /*E1248* E1249 syntax.txt /*E1249* -E125 eval.txt /*E125* +E125 userfunc.txt /*E125* E1250 vim9.txt /*E1250* E1251 vim9.txt /*E1251* E1252 vim9.txt /*E1252* @@ -4340,18 +4343,18 @@ E1256 vim9.txt /*E1256* E1257 vim9.txt /*E1257* E1258 vim9.txt /*E1258* E1259 vim9.txt /*E1259* -E126 eval.txt /*E126* +E126 userfunc.txt /*E126* E1260 vim9.txt /*E1260* E1261 vim9.txt /*E1261* E1262 vim9.txt /*E1262* -E1263 eval.txt /*E1263* +E1263 userfunc.txt /*E1263* E1264 vim9.txt /*E1264* E1265 eval.txt /*E1265* E1266 if_pyth.txt /*E1266* -E1267 eval.txt /*E1267* +E1267 userfunc.txt /*E1267* E1268 vim9.txt /*E1268* E1269 vim9.txt /*E1269* -E127 eval.txt /*E127* +E127 userfunc.txt /*E127* E1270 change.txt /*E1270* E1271 vim9.txt /*E1271* E1272 vim9.txt /*E1272* @@ -4362,7 +4365,7 @@ E1276 builtin.txt /*E1276* E1277 channel.txt /*E1277* E1278 eval.txt /*E1278* E1279 eval.txt /*E1279* -E128 eval.txt /*E128* +E128 userfunc.txt /*E128* E1280 spell.txt /*E1280* E1281 pattern.txt /*E1281* E1282 eval.txt /*E1282* @@ -4373,7 +4376,7 @@ E1286 builtin.txt /*E1286* E1287 builtin.txt /*E1287* E1288 builtin.txt /*E1288* E1289 builtin.txt /*E1289* -E129 eval.txt /*E129* +E129 userfunc.txt /*E129* E1290 change.txt /*E1290* E1291 testing.txt /*E1291* E1292 cmdline.txt /*E1292* @@ -4382,10 +4385,11 @@ E1294 textprop.txt /*E1294* E1295 textprop.txt /*E1295* E1296 textprop.txt /*E1296* E1297 vim9.txt /*E1297* +E1298 vim9.txt /*E1298* E13 message.txt /*E13* -E131 eval.txt /*E131* -E132 eval.txt /*E132* -E133 eval.txt /*E133* +E131 userfunc.txt /*E131* +E132 userfunc.txt /*E132* +E133 userfunc.txt /*E133* E134 change.txt /*E134* E135 autocmd.txt /*E135* E136 starting.txt /*E136* @@ -4450,7 +4454,7 @@ E19 message.txt /*E19* E190 message.txt /*E190* E191 motion.txt /*E191* E192 message.txt /*E192* -E193 eval.txt /*E193* +E193 userfunc.txt /*E193* E194 message.txt /*E194* E195 starting.txt /*E195* E196 various.txt /*E196* @@ -4729,7 +4733,7 @@ E450 popup.txt /*E450* E451 eval.txt /*E451* E452 eval.txt /*E452* E453 syntax.txt /*E453* -E454 eval.txt /*E454* +E454 userfunc.txt /*E454* E455 print.txt /*E455* E456 print.txt /*E456* E457 print.txt /*E457* @@ -5032,13 +5036,13 @@ E737 builtin.txt /*E737* E738 eval.txt /*E738* E739 builtin.txt /*E739* E74 message.txt /*E74* -E740 eval.txt /*E740* +E740 userfunc.txt /*E740* E741 eval.txt /*E741* -E742 eval.txt /*E742* +E742 userfunc.txt /*E742* E743 eval.txt /*E743* E744 netbeans.txt /*E744* E745 eval.txt /*E745* -E746 eval.txt /*E746* +E746 userfunc.txt /*E746* E747 editing.txt /*E747* E748 repeat.txt /*E748* E749 various.txt /*E749* @@ -5155,7 +5159,7 @@ E85 options.txt /*E85* E850 change.txt /*E850* E851 gui_x11.txt /*E851* E852 gui_x11.txt /*E852* -E853 eval.txt /*E853* +E853 userfunc.txt /*E853* E854 options.txt /*E854* E855 autocmd.txt /*E855* E856 testing.txt /*E856* @@ -5189,7 +5193,7 @@ E880 if_pyth.txt /*E880* E881 autocmd.txt /*E881* E882 builtin.txt /*E882* E883 builtin.txt /*E883* -E884 eval.txt /*E884* +E884 userfunc.txt /*E884* E885 sign.txt /*E885* E886 starting.txt /*E886* E887 if_pyth.txt /*E887* @@ -5242,8 +5246,8 @@ E929 starting.txt /*E929* E93 windows.txt /*E93* E930 builtin.txt /*E930* E931 message.txt /*E931* -E932 eval.txt /*E932* -E933 eval.txt /*E933* +E932 userfunc.txt /*E932* +E933 userfunc.txt /*E933* E934 sign.txt /*E934* E935 builtin.txt /*E935* E936 autocmd.txt /*E936* @@ -5304,7 +5308,7 @@ E985 eval.txt /*E985* E986 tagsrch.txt /*E986* E987 tagsrch.txt /*E987* E988 gui_w32.txt /*E988* -E989 eval.txt /*E989* +E989 userfunc.txt /*E989* E99 diff.txt /*E99* E990 eval.txt /*E990* E991 eval.txt /*E991* @@ -5657,7 +5661,7 @@ W18 syntax.txt /*W18* W19 autocmd.txt /*W19* W20 if_pyth.txt /*W20* W21 if_pyth.txt /*W21* -W22 eval.txt /*W22* +W22 userfunc.txt /*W22* WORD motion.txt /*WORD* WSL os_win32.txt /*WSL* WWW intro.txt /*WWW* @@ -5792,12 +5796,12 @@ a' motion.txt /*a'* a( motion.txt /*a(* a) motion.txt /*a)* a4 print.txt /*a4* -a:0 eval.txt /*a:0* -a:000 eval.txt /*a:000* -a:1 eval.txt /*a:1* -a:firstline eval.txt /*a:firstline* -a:lastline eval.txt /*a:lastline* -a:var eval.txt /*a:var* +a:0 userfunc.txt /*a:0* +a:000 userfunc.txt /*a:000* +a:1 userfunc.txt /*a:1* +a:firstline userfunc.txt /*a:firstline* +a:lastline userfunc.txt /*a:lastline* +a:var userfunc.txt /*a:var* a< motion.txt /*a<* a> motion.txt /*a>* aB motion.txt /*aB* @@ -5944,8 +5948,8 @@ autocommand-events autocmd.txt /*autocommand-events* autocommand-pattern autocmd.txt /*autocommand-pattern* autocommands autocmd.txt /*autocommands* autoformat change.txt /*autoformat* -autoload eval.txt /*autoload* -autoload-functions eval.txt /*autoload-functions* +autoload userfunc.txt /*autoload* +autoload-functions userfunc.txt /*autoload-functions* avoid-hit-enter version5.txt /*avoid-hit-enter* aw motion.txt /*aw* a{ motion.txt /*a{* @@ -6582,6 +6586,7 @@ decada_members ft_ada.txt /*decada_members* deepcopy() builtin.txt /*deepcopy()* defaults.vim starting.txt /*defaults.vim* defaults.vim-explained usr_05.txt /*defaults.vim-explained* +define-function userfunc.txt /*define-function* definition-search tagsrch.txt /*definition-search* definitions intro.txt /*definitions* delete() builtin.txt /*delete()* @@ -7221,11 +7226,11 @@ ftplugins usr_05.txt /*ftplugins* fullcommand() builtin.txt /*fullcommand()* funcref() builtin.txt /*funcref()* function() builtin.txt /*function()* -function-argument eval.txt /*function-argument* +function-argument userfunc.txt /*function-argument* function-key intro.txt /*function-key* function-list usr_41.txt /*function-list* -function-range-example eval.txt /*function-range-example* -function-search-undo eval.txt /*function-search-undo* +function-range-example userfunc.txt /*function-range-example* +function-search-undo userfunc.txt /*function-search-undo* function_key intro.txt /*function_key* functions eval.txt /*functions* fuzzy-matching pattern.txt /*fuzzy-matching* @@ -8277,10 +8282,10 @@ lnum-variable eval.txt /*lnum-variable* load-plugins starting.txt /*load-plugins* load-vim-script repeat.txt /*load-vim-script* local-additions help.txt /*local-additions* -local-function eval.txt /*local-function* +local-function userfunc.txt /*local-function* local-options options.txt /*local-options* local-variable eval.txt /*local-variable* -local-variables eval.txt /*local-variables* +local-variables userfunc.txt /*local-variables* local_markfilelist pi_netrw.txt /*local_markfilelist* locale mbyte.txt /*locale* locale-name mbyte.txt /*locale-name* @@ -8943,7 +8948,7 @@ no_plugin_maps filetype.txt /*no_plugin_maps* nocombine syntax.txt /*nocombine* non-greedy pattern.txt /*non-greedy* non-zero-arg eval.txt /*non-zero-arg* -none-function_argument eval.txt /*none-function_argument* +none-function_argument userfunc.txt /*none-function_argument* none-variable eval.txt /*none-variable* normal-index index.txt /*normal-index* not-compatible usr_01.txt /*not-compatible* @@ -8998,7 +9003,7 @@ option-value-function options.txt /*option-value-function* option-window options.txt /*option-window* option_restore() todo.txt /*option_restore()* option_save() todo.txt /*option_save()* -optional-function-argument eval.txt /*optional-function-argument* +optional-function-argument userfunc.txt /*optional-function-argument* options options.txt /*options* options-changed version5.txt /*options-changed* options-in-terminal terminal.txt /*options-in-terminal* @@ -10474,6 +10479,7 @@ user-cmd-ambiguous map.txt /*user-cmd-ambiguous* user-commands map.txt /*user-commands* user-functions eval.txt /*user-functions* user-manual usr_toc.txt /*user-manual* +userfunc.txt userfunc.txt /*userfunc.txt* using- usr_51.txt /*using-* using-menus gui.txt /*using-menus* using-scripts repeat.txt /*using-scripts* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index 327ae01f4d..71b8b0f07c 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -38,12 +38,17 @@ browser use: https://github.com/vim/vim/issues/1234 *known-bugs* -------------------- Known bugs and current work ----------------------- -cmdheight=0: -- :g/pattern should not use message window #11012 +When using :echomessage do use msg_row and msg_col, but save and restore. +How to test any failure? -*.sil detection with FTsil() (lacygoill, Aug 25) +Improve :defer command: + - Use "D" flag of writefile() in tests. + - test "defer func()->funcouter()" fails (or use "funcouter") + - test "defer func().arg" fails + - test partial fails + - check arguments at :defer command + - Also when function does "qa!" or "cq"? -Avoid using "Xfile" and "Xdir" in tests, use specific names. Further Vim9 improvements, possibly after launch: - Use Vim9 for more runtime files. @@ -183,10 +188,7 @@ Terminal emulator window: - When 'encoding' is not utf-8, or the job is using another encoding, setup conversions. -Cleanup: -- Remove FEAT_FOOTER ? - -Add 'splitscroll' #10682 Useful? Any remaining trouble? +Add 'splitscroll' #10682 Anything remaining Autoconf: must use autoconf 2.69, later version generates lots of warnings - try using autoconf 2.71 and fix all "obsolete" warnings @@ -196,6 +198,8 @@ Can deref_func_name() and deref_function_name() be merged? After patch 8.2.4915 w_botline is computed much more often. Can this be reduced? +Add BufDeletePost. #11041 + NFA regexp does not handle composing characters well: #10286 [ɔ̃] matches both ɔ and ɔ̃ \(ɔ\|ɔ̃\) matches ɔ and not ɔ̃ @@ -3753,6 +3757,7 @@ Syntax highlighting: - use treesitter, NeoVim uses it - Many people don't like it. After changes requires rebuilding the library. - use TextMate, vscode uses it. #9087 - Other people don't like it. + https://github.com/icedman/vim-textmate Vscode is asked to switch to treesitter: https://github.com/microsoft/vscode/issues/50140 - sublime grammar? diff --git a/runtime/doc/userfunc.txt b/runtime/doc/userfunc.txt new file mode 100644 index 0000000000..f6377009b8 --- /dev/null +++ b/runtime/doc/userfunc.txt @@ -0,0 +1,530 @@ +*userfunc.txt* For Vim version 9.0. Last change: 2022 Jun 17 + + + VIM REFERENCE MANUAL by Bram Moolenaar + + +Defining and using functions. + +This is introduced in section |41.7| of the user manual. + +1. Defining a fuction |define-function| +2. Calling a fuction |:call| +3. Cleaning up in a function |:defer| +4. Automatically loading functions |autoload-functions| + +============================================================================== + +1. Defining a fuction ~ + *define-function* +New functions can be defined. These can be called just like builtin +functions. The function executes a sequence of Ex commands. Normal mode +commands can be executed with the |:normal| command. + +The function name must start with an uppercase letter, to avoid confusion with +builtin functions. To prevent from using the same name in different scripts +make them script-local. If you do use a global function the avoid obvious, +short names. A good habit is to start the function name with the name of the +script, e.g., "HTMLcolor()". + +In legacy script it is also possible to use curly braces, see +|curly-braces-names|. + +The |autoload| facility is useful to define a function only when it's called. + + *local-function* +A function local to a legacy script must start with "s:". A local script +function can only be called from within the script and from functions, user +commands and autocommands defined in the script. It is also possible to call +the function from a mapping defined in the script, but then || must be +used instead of "s:" when the mapping is expanded outside of the script. +There are only script-local functions, no buffer-local or window-local +functions. + +In |Vim9| script functions are local to the script by default, prefix "g:" to +define a global function. + + *:fu* *:function* *E128* *E129* *E123* *E454* +:fu[nction] List all functions and their arguments. + +:fu[nction] {name} List function {name}. + {name} can also be a |Dictionary| entry that is a + |Funcref|: > + :function dict.init + +:fu[nction] /{pattern} List functions with a name matching {pattern}. + Example that lists all functions ending with "File": > + :function /File$ +< + *:function-verbose* +When 'verbose' is non-zero, listing a function will also display where it was +last defined. Example: > + + :verbose function SetFileTypeSH + function SetFileTypeSH(name) + Last set from /usr/share/vim/vim-7.0/filetype.vim +< +See |:verbose-cmd| for more information. + + *E124* *E125* *E853* *E884* +:fu[nction][!] {name}([arguments]) [range] [abort] [dict] [closure] + Define a new function by the name {name}. The body of + the function follows in the next lines, until the + matching |:endfunction|. + *E1267* + The name must be made of alphanumeric characters and + '_', and must start with a capital or "s:" (see + above). Note that using "b:" or "g:" is not allowed. + (since patch 7.4.260 E884 is given if the function + name has a colon in the name, e.g. for "foo:bar()". + Before that patch no error was given). + + {name} can also be a |Dictionary| entry that is a + |Funcref|: > + :function dict.init(arg) +< "dict" must be an existing dictionary. The entry + "init" is added if it didn't exist yet. Otherwise [!] + is required to overwrite an existing function. The + result is a |Funcref| to a numbered function. The + function can only be used with a |Funcref| and will be + deleted if there are no more references to it. + *E127* *E122* + When a function by this name already exists and [!] is + not used an error message is given. There is one + exception: When sourcing a script again, a function + that was previously defined in that script will be + silently replaced. + When [!] is used, an existing function is silently + replaced. Unless it is currently being executed, that + is an error. + NOTE: Use ! wisely. If used without care it can cause + an existing function to be replaced unexpectedly, + which is hard to debug. + NOTE: In Vim9 script script-local functions cannot be + deleted or redefined. + + For the {arguments} see |function-argument|. + + *:func-range* *a:firstline* *a:lastline* + When the [range] argument is added, the function is + expected to take care of a range itself. The range is + passed as "a:firstline" and "a:lastline". If [range] + is excluded, ":{range}call" will call the function for + each line in the range, with the cursor on the start + of each line. See |function-range-example|. + The cursor is still moved to the first line of the + range, as is the case with all Ex commands. + *:func-abort* + When the [abort] argument is added, the function will + abort as soon as an error is detected. + *:func-dict* + When the [dict] argument is added, the function must + be invoked through an entry in a |Dictionary|. The + local variable "self" will then be set to the + dictionary. See |Dictionary-function|. + *:func-closure* *E932* + When the [closure] argument is added, the function + can access variables and arguments from the outer + scope. This is usually called a closure. In this + example Bar() uses "x" from the scope of Foo(). It + remains referenced even after Foo() returns: > + :function! Foo() + : let x = 0 + : function! Bar() closure + : let x += 1 + : return x + : endfunction + : return funcref('Bar') + :endfunction + + :let F = Foo() + :echo F() +< 1 > + :echo F() +< 2 > + :echo F() +< 3 + + *function-search-undo* + The last used search pattern and the redo command "." + will not be changed by the function. This also + implies that the effect of |:nohlsearch| is undone + when the function returns. + + *:endf* *:endfunction* *E126* *E193* *W22* *E1151* +:endf[unction] [argument] + The end of a function definition. Best is to put it + on a line by its own, without [argument]. + + [argument] can be: + | command command to execute next + \n command command to execute next + " comment always ignored + anything else ignored, warning given when + 'verbose' is non-zero + The support for a following command was added in Vim + 8.0.0654, before that any argument was silently + ignored. + + To be able to define a function inside an `:execute` + command, use line breaks instead of |:bar|: > + :exe "func Foo()\necho 'foo'\nendfunc" +< + *:delf* *:delfunction* *E131* *E933* *E1084* +:delf[unction][!] {name} + Delete function {name}. + {name} can also be a |Dictionary| entry that is a + |Funcref|: > + :delfunc dict.init +< This will remove the "init" entry from "dict". The + function is deleted if there are no more references to + it. + With the ! there is no error if the function does not + exist. + *:retu* *:return* *E133* +:retu[rn] [expr] Return from a function. When "[expr]" is given, it is + evaluated and returned as the result of the function. + If "[expr]" is not given, the number 0 is returned. + When a function ends without an explicit ":return", + the number 0 is returned. + In a :def function *E1095* is given if unreachable + code follows after the `:return`. + In legacy script there is no check for unreachable + lines, thus there is no warning if commands follow + `:return`. + + If the ":return" is used after a |:try| but before the + matching |:finally| (if present), the commands + following the ":finally" up to the matching |:endtry| + are executed first. This process applies to all + nested ":try"s inside the function. The function + returns at the outermost ":endtry". + + *function-argument* *a:var* +An argument can be defined by giving its name. In the function this can then +be used as "a:name" ("a:" for argument). + *a:0* *a:1* *a:000* *E740* *...* +Up to 20 arguments can be given, separated by commas. After the named +arguments an argument "..." can be specified, which means that more arguments +may optionally be following. In the function the extra arguments can be used +as "a:1", "a:2", etc. "a:0" is set to the number of extra arguments (which +can be 0). "a:000" is set to a |List| that contains these arguments. Note +that "a:1" is the same as "a:000[0]". + *E742* *E1090* +The a: scope and the variables in it cannot be changed, they are fixed. +However, if a composite type is used, such as |List| or |Dictionary| , you can +change their contents. Thus you can pass a |List| to a function and have the +function add an item to it. If you want to make sure the function cannot +change a |List| or |Dictionary| use |:lockvar|. + +It is also possible to define a function without any arguments. You must +still supply the () then. + +It is allowed to define another function inside a function body. + + *optional-function-argument* +You can provide default values for positional named arguments. This makes +them optional for function calls. When a positional argument is not +specified at a call, the default expression is used to initialize it. +This only works for functions declared with `:function` or `:def`, not for +lambda expressions |expr-lambda|. + +Example: > + function Something(key, value = 10) + echo a:key .. ": " .. a:value + endfunction + call Something('empty') "empty: 10" + call Something('key', 20) "key: 20" + +The argument default expressions are evaluated at the time of the function +call, not definition. Thus it is possible to use an expression which is +invalid the moment the function is defined. The expressions are also only +evaluated when arguments are not specified during a call. + *none-function_argument* +You can pass |v:none| to use the default expression. Note that this means you +cannot pass v:none as an ordinary value when an argument has a default +expression. + +Example: > + function Something(a = 10, b = 20, c = 30) + endfunction + call Something(1, v:none, 3) " b = 20 +< + *E989* +Optional arguments with default expressions must occur after any mandatory +arguments. You can use "..." after all optional named arguments. + +It is possible for later argument defaults to refer to prior arguments, +but not the other way around. They must be prefixed with "a:", as with all +arguments. + +Example that works: > + :function Okay(mandatory, optional = a:mandatory) + :endfunction +Example that does NOT work: > + :function NoGood(first = a:second, second = 10) + :endfunction +< +When not using "...", the number of arguments in a function call must be at +least equal to the number of mandatory named arguments. When using "...", the +number of arguments may be larger than the total of mandatory and optional +arguments. + + *local-variables* +Inside a function local variables can be used. These will disappear when the +function returns. Global variables need to be accessed with "g:". +Inside functions local variables are accessed without prepending anything. +But you can also prepend "l:" if you like. This is required for some reserved +names, such as "count". + +Example: > + :function Table(title, ...) + : echohl Title + : echo a:title + : echohl None + : echo a:0 .. " items:" + : for s in a:000 + : echon ' ' .. s + : endfor + :endfunction + +This function can then be called with: > + call Table("Table", "line1", "line2") + call Table("Empty Table") + +To return more than one value, return a |List|: > + :function Compute(n1, n2) + : if a:n2 == 0 + : return ["fail", 0] + : endif + : return ["ok", a:n1 / a:n2] + :endfunction + +This function can then be called with: > + :let [success, div] = Compute(102, 6) + :if success == "ok" + : echo div + :endif +< +============================================================================== + +2. Calling a fuction ~ + *:cal* *:call* *E107* +:[range]cal[l] {name}([arguments]) + Call a function. The name of the function and its arguments + are as specified with `:function`. Up to 20 arguments can be + used. The returned value is discarded. + In |Vim9| script using `:call` is optional, these two lines do + the same thing: > + call SomeFunc(arg) + SomeFunc(arg) +< Without a range and for functions that accept a range, the + function is called once. When a range is given the cursor is + positioned at the start of the first line before executing the + function. + When a range is given and the function doesn't handle it + itself, the function is executed for each line in the range, + with the cursor in the first column of that line. The cursor + is left at the last line (possibly moved by the last function + call). The arguments are re-evaluated for each line. Thus + this works: + *function-range-example* > + :function Mynumber(arg) + : echo line(".") .. " " .. a:arg + :endfunction + :1,5call Mynumber(getline(".")) +< + The "a:firstline" and "a:lastline" are defined anyway, they + can be used to do something different at the start or end of + the range. + + Example of a function that handles the range itself: > + + :function Cont() range + : execute (a:firstline + 1) .. "," .. a:lastline .. 's/^/\t\\ ' + :endfunction + :4,8call Cont() +< + This function inserts the continuation character "\" in front + of all the lines in the range, except the first one. + + When the function returns a composite value it can be further + dereferenced, but the range will not be used then. Example: > + :4,8call GetDict().method() +< Here GetDict() gets the range but method() does not. + + *E117* +When a function cannot be found the error "E117: Unknown function" will be +given. If the function was using an autoload path or an autoload import and +the script is a |Vim9| script, this may also be caused by the function not +being exported. + + *E132* +The recursiveness of user functions is restricted with the |'maxfuncdepth'| +option. + +It is also possible to use `:eval`. It does not support a range, but does +allow for method chaining, e.g.: > + eval GetList()->Filter()->append('$') + +A function can also be called as part of evaluating an expression or when it +is used as a method: > + let x = GetList() + let y = GetList()->Filter() + +============================================================================== + +3. Cleaning up in a function ~ + *:defer* +:defer {func}({args}) Call {func} when the current function is done. + {args} are evaluated here. + +Quite often a command in a function has a global effect, which must be undone +when the function finishes. Handling this in all kinds of situations can be a +hassle. Especially when an unexpected error is encountered. This can be done +with `try` / `finally` blocks, but this gets complicated when there is more +than one. + +A much simpler solution is using `defer`. It schedules a function call when +the function is returning, no matter if there is an error. Example: > + func Filter(text) abort + call writefile(a:text, 'Tempfile') + call system('filter < Tempfile > Outfile') + call Handle('Outfile') + call delete('Tempfile') + call delete('Outfile') + endfunc + +Here 'Tempfile' and 'Outfile' will not be deleted if something causes the +function to abort. `:defer` can be used to avoid that: > + func Filter(text) abort + call writefile(a:text, 'Tempfile') + defer delete('Tempfile') + defer delete('Outfile') + call system('filter < Tempfile > Outfile') + call Handle('Outfile') + endfunc + +Note that deleting "Outfile" is scheduled before calling system(), since it +can be created even when `system()` fails. + +The deferred functions are called in reverse order, the last one added is +executed first. A useless example: > + func Useless() abort + for s in range(3) + defer execute('echomsg "number ' .. s .. '"') + endfor + endfunc + +Now `:messages` shows: + number 2 + number 1 + number 0 + +Any return value of the deferred function is discarded. The function cannot +be followed by anything, such as "->func" or ".member". Currently `:defer +GetArg()->TheFunc()` does not work, it may work in a later version. + +Errors are reported but do not cause aborting execution of deferred functions. + +No range is accepted. + +============================================================================== + +4. Automatically loading functions ~ + *autoload-functions* +When using many or large functions, it's possible to automatically define them +only when they are used. There are two methods: with an autocommand and with +the "autoload" directory in 'runtimepath'. + +In |Vim9| script there is also an autoload mechanism for imported scripts, see +|import-autoload|. + + +Using an autocommand ~ + +This is introduced in the user manual, section |51.4|. + +The autocommand is useful if you have a plugin that is a long Vim script file. +You can define the autocommand and quickly quit the script with `:finish`. +That makes Vim startup faster. The autocommand should then load the same file +again, setting a variable to skip the `:finish` command. + +Use the FuncUndefined autocommand event with a pattern that matches the +function(s) to be defined. Example: > + + :au FuncUndefined BufNet* source ~/vim/bufnetfuncs.vim + +The file "~/vim/bufnetfuncs.vim" should then define functions that start with +"BufNet". Also see |FuncUndefined|. + + +Using an autoload script ~ + *autoload* *E746* +This is introduced in the user manual, section |52.2|. + +Using a script in the "autoload" directory is simpler, but requires using +exactly the right file name. A function that can be autoloaded has a name +like this: > + + :call filename#funcname() + +These functions are always global, in Vim9 script "g:" needs to be used: > + :call g:filename#funcname() + +When such a function is called, and it is not defined yet, Vim will search the +"autoload" directories in 'runtimepath' for a script file called +"filename.vim". For example "~/.vim/autoload/filename.vim". That file should +then define the function like this: > + + function filename#funcname() + echo "Done!" + endfunction + +The file name and the name used before the # in the function must match +exactly, and the defined function must have the name exactly as it will be +called. In Vim9 script the "g:" prefix must be used: > + function g:filename#funcname() + +or for a compiled function: > + def g:filename#funcname() + +It is possible to use subdirectories. Every # in the function name works like +a path separator. Thus when calling a function: > + + :call foo#bar#func() + +Vim will look for the file "autoload/foo/bar.vim" in 'runtimepath'. + +This also works when reading a variable that has not been set yet: > + + :let l = foo#bar#lvar + +However, when the autoload script was already loaded it won't be loaded again +for an unknown variable. + +When assigning a value to such a variable nothing special happens. This can +be used to pass settings to the autoload script before it's loaded: > + + :let foo#bar#toggle = 1 + :call foo#bar#func() + +Note that when you make a mistake and call a function that is supposed to be +defined in an autoload script, but the script doesn't actually define the +function, you will get an error message for the missing function. If you fix +the autoload script it won't be automatically loaded again. Either restart +Vim or manually source the script. + +Also note that if you have two script files, and one calls a function in the +other and vice versa, before the used function is defined, it won't work. +Avoid using the autoload functionality at the toplevel. + +In |Vim9| script you will get error *E1263* if you define a function with +a "#" character in the name. You should use a name without "#" and use +`:export`. + +Hint: If you distribute a bunch of scripts you can pack them together with the +|vimball| utility. Also read the user manual |distribute-script|. + + + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index 32ec10211f..b60d44c5d9 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -257,13 +257,13 @@ and 'winminwidth' are relevant. :vert[ical] {cmd} Execute {cmd}. If it contains a command that splits a window, it will be split vertically. For `vertical wincmd =` windows - will be equialized only vertically. + will be equalized only vertically. Doesn't work for |:execute| and |:normal|. *:hor* *:horizontal* :hor[izontal] {cmd} Execute {cmd}. Currently only makes a difference for - `horizontal wincmd =`, which will equal windows only + `horizontal wincmd =`, which will equalize windows only horizontally. :lefta[bove] {cmd} *:lefta* *:leftabove* diff --git a/runtime/ftplugin/gdscript.vim b/runtime/ftplugin/gdscript.vim index dc1d220d06..3597d45d88 100644 --- a/runtime/ftplugin/gdscript.vim +++ b/runtime/ftplugin/gdscript.vim @@ -3,6 +3,7 @@ vim9script # Vim filetype plugin file # Language: gdscript (Godot game engine scripting language) # Maintainer: Maxim Kim +# Website: https://github.com/habamax/vim-gdscript if exists("b:did_ftplugin") | finish | endif @@ -49,5 +50,5 @@ enddef nnoremap ]] NextSection(false, v:count1) nnoremap [[ NextSection(true, v:count1) -xmap ]] "\" .. v:count1 .. ']]m>gv' -xmap [[ "\" .. v:count1 .. '[[m>gv' +xmap ]] $'{v:count1}]]m>gv' +xmap [[ $'{v:count1}[[m>gv' diff --git a/runtime/indent/testdir/runtest.vim b/runtime/indent/testdir/runtest.vim index 6bbd33cacd..fa4e16e381 100644 --- a/runtime/indent/testdir/runtest.vim +++ b/runtime/indent/testdir/runtest.vim @@ -11,6 +11,7 @@ syn on set nowrapscan set report=9999 set modeline +set debug=throw au! SwapExists * call HandleSwapExists() func HandleSwapExists() @@ -84,7 +85,12 @@ for fname in glob('testdir/*.in', 1, 1) exe start + 1 if pattern == '' - exe 'normal =' . (end - 1) . 'G' + try + exe 'normal =' . (end - 1) . 'G' + catch + call append(indent_at, 'ERROR: ' . v:exception) + let failed = 1 + endtry else let lnum = search(pattern) if lnum <= 0 @@ -99,7 +105,12 @@ for fname in glob('testdir/*.in', 1, 1) else exe lnum - 1 endif - normal == + try + normal == + catch + call append(indent_at, 'ERROR: ' . v:exception) + let failed = 1 + endtry endif endif endwhile diff --git a/runtime/indent/testdir/vim.in b/runtime/indent/testdir/vim.in index 873045bc2c..5eb262f50a 100644 --- a/runtime/indent/testdir/vim.in +++ b/runtime/indent/testdir/vim.in @@ -36,6 +36,13 @@ let t = [ \ }, \ ] +def Func() + var d = dd + ->extend({ + }) + eval 0 +enddef + " END_INDENT " START_INDENT diff --git a/runtime/indent/testdir/vim.ok b/runtime/indent/testdir/vim.ok index 8e70abe619..932eebef43 100644 --- a/runtime/indent/testdir/vim.ok +++ b/runtime/indent/testdir/vim.ok @@ -36,6 +36,13 @@ let t = [ \ }, \ ] +def Func() + var d = dd + ->extend({ + }) + eval 0 +enddef + " END_INDENT " START_INDENT diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim index 8a2502a275..2ae3658a4b 100644 --- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -33,7 +33,9 @@ function GetVimIndent() endtry endfunc -let s:lineContPat = '^\s*\(\\\|"\\ \)' +" Legacy script line continuation and Vim9 script operators that must mean an +" expression that continues from the previous line. +let s:lineContPat = '^\s*\(\\\|"\\ \|->\)' function GetVimIndentIntern() " If the current line has line continuation and the previous one too, use @@ -133,15 +135,15 @@ function GetVimIndentIntern() endif endif - " For a line starting with "}" find the matching "{". If it is at the start - " of the line align with it, probably end of a block. + " For a line starting with "}" find the matching "{". Align with that line, + " it is either the matching block start or dictionary start. " Use the mapped "%" from matchit to find the match, otherwise we may match " a { inside a comment or string. if cur_text =~ '^\s*}' if maparg('%') != '' exe v:lnum silent! normal % - if line('.') < v:lnum && getline('.') =~ '^\s*{' + if line('.') < v:lnum let ind = indent('.') endif else @@ -149,19 +151,33 @@ function GetVimIndentIntern() endif endif - " Below a line starting with "}" find the matching "{". If it is at the - " end of the line we must be below the end of a dictionary. - if prev_text =~ '^\s*}' - if maparg('%') != '' - exe lnum - silent! normal % - if line('.') == lnum || getline('.') !~ '^\s*{' - let ind = ind - shiftwidth() + " Look back for a line to align with + while lnum > 1 + " Below a line starting with "}" find the matching "{". + if prev_text =~ '^\s*}' + if maparg('%') != '' + exe lnum + silent! normal % + if line('.') < lnum + let lnum = line('.') + let ind = indent(lnum) + let prev_text = getline(lnum) + else + break + endif + else + " todo: use searchpair() to find a match + break endif + elseif prev_text =~ s:lineContPat + " looks like a continuation like, go back one line + let lnum = lnum - 1 + let ind = indent(lnum) + let prev_text = getline(lnum) else - " todo: use searchpair() to find a match + break endif - endif + endwhile " Below a line starting with "]" we must be below the end of a list. " Include a "}" and "},} in case a dictionary ends too. diff --git a/runtime/indent/yaml.vim b/runtime/indent/yaml.vim index d732c37c05..93fd8ea6f6 100644 --- a/runtime/indent/yaml.vim +++ b/runtime/indent/yaml.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: YAML " Maintainer: Nikolai Pavlov -" Last Update: Lukas Reineke +" Last Updates: Lukas Reineke, "lacygoill" " Last Change: 2022 Jun 17 " Only load this indent file when no other was loaded. @@ -29,8 +29,8 @@ function s:FindPrevLessIndentedLine(lnum, ...) let prevlnum = prevnonblank(a:lnum-1) let curindent = a:0 ? a:1 : indent(a:lnum) while prevlnum - \&& indent(prevlnum) >= curindent - \&& getline(prevlnum) !~# '^\s*#' + \ && indent(prevlnum) >= curindent + \ && getline(prevlnum) !~# '^\s*#' let prevlnum = prevnonblank(prevlnum-1) endwhile return prevlnum @@ -54,7 +54,7 @@ let s:c_ns_anchor_name = s:c_ns_anchor_char .. '+' let s:c_ns_anchor_property = '\v\&' .. s:c_ns_anchor_name let s:ns_word_char = '\v[[:alnum:]_\-]' -let s:ns_tag_char = '\v%(%\x\x|' .. s:ns_word_char .. '|[#/;?:@&=+$.~*''()])' +let s:ns_tag_char = '\v%(\x\x|' .. s:ns_word_char .. '|[#/;?:@&=+$.~*''()])' let s:c_named_tag_handle = '\v\!' .. s:ns_word_char .. '+\!' let s:c_secondary_tag_handle = '\v\!\!' let s:c_primary_tag_handle = '\v\!' @@ -63,7 +63,7 @@ let s:c_tag_handle = '\v%(' .. s:c_named_tag_handle. \ '|' .. s:c_primary_tag_handle .. ')' let s:c_ns_shorthand_tag = '\v' .. s:c_tag_handle .. s:ns_tag_char .. '+' let s:c_non_specific_tag = '\v\!' -let s:ns_uri_char = '\v%(%\x\x|' .. s:ns_word_char .. '\v|[#/;?:@&=+$,.!~*''()[\]])' +let s:ns_uri_char = '\v%(\x\x|' .. s:ns_word_char .. '\v|[#/;?:@&=+$,.!~*''()[\]])' let s:c_verbatim_tag = '\v\!\<' .. s:ns_uri_char.. '+\>' let s:c_ns_tag_property = '\v' .. s:c_verbatim_tag. \ '\v|' .. s:c_ns_shorthand_tag. diff --git a/runtime/syntax/gdresource.vim b/runtime/syntax/gdresource.vim index eb500aa6c2..7e1a2513e2 100644 --- a/runtime/syntax/gdresource.vim +++ b/runtime/syntax/gdresource.vim @@ -2,12 +2,13 @@ " Language: gdresource " Maintainer: Maxim Kim " Filenames: *.tscn, *.tres +" Website: https://github.com/habamax/vim-gdscript if exists("b:current_syntax") finish endif -let s:keepcpo= &cpo +let s:keepcpo = &cpo set cpo&vim syn match gdResourceNumber "\<0x\%(_\=\x\)\+\>" diff --git a/runtime/syntax/gdscript.vim b/runtime/syntax/gdscript.vim index bf6d47c60d..e9295a411d 100644 --- a/runtime/syntax/gdscript.vim +++ b/runtime/syntax/gdscript.vim @@ -1,13 +1,14 @@ " Vim syntax file for Godot gdscript " Language: gdscript " Maintainer: Maxim Kim +" Website: https://github.com/habamax/vim-gdscript " Filenames: *.gd if exists("b:current_syntax") finish endif -let s:keepcpo= &cpo +let s:keepcpo = &cpo set cpo&vim syntax sync maxlines=100 diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim index e44699faa5..822b1a9ed2 100644 --- a/runtime/syntax/sh.vim +++ b/runtime/syntax/sh.vim @@ -2,8 +2,8 @@ " Language: shell (sh) Korn shell (ksh) bash (sh) " Maintainer: Charles E. Campbell " Previous Maintainer: Lennart Schultz -" Last Change: Jun 29, 2022 -" Version: 202 +" Last Change: Jul 08, 2022 +" Version: 203 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH " For options and settings, please use: :help ft-sh-syntax " This file includes many ideas from Eric Brunet (eric.brunet@ens.fr) and heredoc fixes from Felipe Contreras @@ -141,7 +141,7 @@ endif syn cluster shArithParenList contains=shArithmetic,shArithParen,shCaseEsac,shComment,shDeref,shDo,shDerefSimple,shEcho,shEscape,shNumber,shOperator,shPosnParm,shExSingleQuote,shExDoubleQuote,shHereString,shRedir,shSingleQuote,shDoubleQuote,shStatement,shVariable,shAlias,shTest,shCtrlSeq,shSpecial,shParen,bashSpecialVariables,bashStatement,shIf,shFor,shFunctionKey,shFunctionOne,shFunctionTwo syn cluster shArithList contains=@shArithParenList,shParenError syn cluster shCaseEsacList contains=shCaseStart,shCaseLabel,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote,shCtrlSeq,@shErrorList,shStringSpecial,shCaseRange -syn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shCommandSubBQ,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq +syn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shCommandSubBQ,shComment,shDblBrace,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq if exists("b:is_kornshell") || exists("b:is_bash") syn cluster shCaseList add=shForPP endif diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 3656bca05e..694b3a7d95 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: Vim 9.0 script " Maintainer: Charles E. Campbell -" Last Change: August 17, 2022 -" Version: 9.0-02 +" Last Change: September 03, 2022 +" Version: 9.0-03 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_VIM " Automatically generated keyword lists: {{{1 @@ -19,12 +19,13 @@ syn keyword vimTodo contained COMBAK FIXME TODO XXX syn cluster vimCommentGroup contains=vimTodo,@Spell " regular vim commands {{{2 -syn keyword vimCommand contained a al[l] arge[dit] bN[ext] bel[owright] bp[revious] bro[wse] cNf[ile] cadde[xpr] cbe[fore] cdo cg[etfile] checkt[ime] clo[se] co[py] con[tinue] cq[uit] cuna[bbrev] defc[ompile] deletl dep diffpu[t] dj[ump] dp earlier el[se] endenum ene[w] export filt[er] fo[ld] fu[nction] h[elp] hi if in iuna[bbrev] keepalt la[st] lan[guage] lbo[ttom] ld[o] lfdo lgrepa[dd] lma lo[adview] lop[en] lua m[ove] mes[sages] mod[e] nbs[tart] nor omapc[lear] packl[oadall] popu[p] profd[el] ptf[irst] pts[elect] py3f[ile] pyx r[ead] redrawt[abline] ri[ght] rundo sIl sal[l] sbf[irst] sc scp se[t] sg sgn sie sip sme snoremenu spelli[nfo] spr[evious] sri star[tinsert] sts[elect] sus[pend] syncbind tabN[ext] tabl[ast] tabr[ewind] tcld[o] tj[ump] tlu tno[remap] tu[nmenu] undol[ist] v vie[w] vne[w] win[size] wq xmapc[lear] xr[estore] -syn keyword vimCommand contained ab ar[gs] argg[lobal] b[uffer] bf[irst] br[ewind] bufdo c[hange] caddf[ile] cbel[ow] ce[nter] cgetb[uffer] chi[story] cmapc[lear] col[der] conf[irm] cr[ewind] cw[indow] delc[ommand] deletp di[splay] diffs[plit] dl dr[op] ec elsei[f] endf[unction] enum exu[sage] fin[d] foldc[lose] go[to] ha[rdcopy] hid[e] ij[ump] inor j[oin] keepj[umps] lab[ove] lat lc[d] le[ft] lfir[st] lh[elpgrep] lmak[e] loadk lp[revious] luado ma[rk] mk[exrc] mz[scheme] new nore on[ly] pc[lose] pp[op] promptf[ind] ptj[ump] pu[t] py[thon] pyxdo rec[over] reg[isters] rightb[elow] rv[iminfo] sIn san[dbox] sbl[ast] scI scr[iptnames] setf[iletype] sgI sgp sig sir smenu so[urce] spellr[are] sr srl startg[replace] substitutepattern sv[iew] syntime tabc[lose] tabm[ove] tabs tclf[ile] tl[ast] tlunmenu to[pleft] tunma[p] unh[ide] var vim9[cmd] vs[plit] winc[md] wqa[ll] xme xunme -syn keyword vimCommand contained abc[lear] arga[dd] argl[ocal] ba[ll] bl[ast] brea[k] buffers ca caf[ter] cbo[ttom] cex[pr] cgete[xpr] cl[ist] cn[ext] colo[rscheme] cons[t] cs d[elete] delel delf[unction] dif[fupdate] difft[his] dli[st] ds[earch] echoc[onsole] em[enu] endfo[r] eval f[ile] fina[lly] foldd[oopen] gr[ep] helpc[lose] his[tory] il[ist] interface ju[mps] keepp[atterns] lad[dexpr] later lch[dir] lefta[bove] lg[etfile] lhi[story] lmapc[lear] loadkeymap lpf[ile] luafile mak[e] mks[ession] mzf[ile] nmapc[lear] nos[wapfile] opt[ions] pe[rl] pre[serve] promptr[epl] ptl[ast] pw[d] pydo pyxfile red[o] res[ize] ru[ntime] sI sIp sav[eas] sbm[odified] sce scripte[ncoding] setg[lobal] sgc sgr sign sl[eep] smile sor[t] spellr[epall] srI srn startr[eplace] substituterepeat sw[apname] t tabd[o] tabn[ext] tags te[aroff] tlm tm[enu] tp[revious] type unl ve[rsion] vim9s[cript] wN[ext] windo wundo xmenu xunmenu -syn keyword vimCommand contained abo[veleft] argd[elete] argu[ment] bad[d] bm[odified] breaka[dd] bun[load] cabc[lear] cal[l] cc cf[ile] changes cla[st] cnew[er] com cope[n] cscope debug delep dell diffg[et] dig[raphs] do dsp[lit] echoe[rr] en[dif] endinterface ex files fini[sh] folddoc[losed] grepa[dd] helpf[ind] i imapc[lear] intro k lN[ext] laddb[uffer] lb[uffer] lcl[ose] leg[acy] lgetb[uffer] ll lne[xt] loc[kmarks] lr[ewind] lv[imgrep] marks mksp[ell] n[ext] noa nu[mber] ownsyntax ped[it] prev[ious] ps[earch] ptn[ext] py3 pyf[ile] q[uit] redi[r] ret[ab] rub[y] sIc sIr sbN[ext] sbn[ext] scg scriptv[ersion] setl[ocal] sge sh[ell] sil[ent] sla[st] sn[ext] sp[lit] spellr[rare] src srp static sun[hide] sy tN[ext] tabe[dit] tabnew tc[d] ter[minal] tlmenu tma[p] tr[ewind] u[ndo] unlo[ckvar] verb[ose] vim[grep] w[rite] winp[os] wv[iminfo] xnoreme xwininfo -syn keyword vimCommand contained abstract argded[upe] as[cii] balt bn[ext] breakd[el] bw[ipeout] cabo[ve] cat[ch] ccl[ose] cfdo chd[ir] class cnf[ile] comc[lear] cp[revious] cstag debugg[reedy] deletel delm[arks] diffo[ff] dir doau e[dit] echom[sg] endclass endt[ry] exi[t] filet fir[st] foldo[pen] gui helpg[rep] ia imp is[earch] kee[pmarks] lNf[ile] laddf[ile] lbe[fore] lcs lex[pr] lgete[xpr] lla[st] lnew[er] lockv[ar] ls lvimgrepa[dd] mat[ch] mkv[imrc] nb[key] noautocmd o[pen] p[rint] perld[o] pro ptN[ext] ptp[revious] py3do python3 qa[ll] redr[aw] retu[rn] rubyd[o] sIe sN[ext] sb[uffer] sbp[revious] sci scs sf[ind] sgi si sim[alt] sm[agic] sno[magic] spe[llgood] spellu[ndo] sre[wind] st[op] stj[ump] sunme syn ta[g] tabf[ind] tabo[nly] tch[dir] tf[irst] tln tmapc[lear] try una[bbreviate] uns[ilent] vert[ical] vimgrepa[dd] wa[ll] wn[ext] x[it] xnoremenu y[ank] -syn keyword vimCommand contained addd argdo au bd[elete] bo[tright] breakl[ist] cN[ext] cad[dbuffer] cb[uffer] cd cfir[st] che[ckpath] cle[arjumps] cnor comp[iler] cpf[ile] cun def deletep delp diffp[atch] disa[ssemble] doaut ea echon enddef endw[hile] exp filetype fix[del] for gvim helpt[ags] iabc[lear] import isp[lit] keepa l[ist] laf[ter] lbel[ow] lcscope lf[ile] lgr[ep] lli[st] lnf[ile] lol[der] lt[ag] lw[indow] menut[ranslate] mkvie[w] nbc[lose] noh[lsearch] ol[dfiles] pa[ckadd] po[p] prof[ile] pta[g] ptr[ewind] py3f[ile] pythonx quita[ll] redraws[tatus] rew[ind] rubyf[ile] sIg sa[rgument] sba[ll] sbr[ewind] scl scscope sfir[st] sgl sic sin sm[ap] snoreme spelld[ump] spellw[rong] srg sta[g] stopi[nsert] sunmenu sync tab tabfir[st] tabp[revious] tcl th[row] tlnoremenu tn[ext] ts[elect] undoj[oin] up[date] vi[sual] viu[sage] wh[ile] wp[revious] xa[ll] xprop z[^.=] +syn keyword vimCommand contained a ar[gs] argl[ocal] ba[ll] bl[ast] brea[k] buffers ca caf[ter] cbo[ttom] cex[pr] cgete[xpr] cl[ist] cn[ext] colo[rscheme] cons[t] cs d[elete] delel delf[unction] dif[fupdate] difft[his] dli[st] ds[earch] echoc[onsole] elsei[f] endf[unction] enum exu[sage] fin[d] foldc[lose] go[to] ha[rdcopy] hid[e] if in iuna[bbrev] keepalt la[st] lan[guage] lbo[ttom] ld[o] lfdo lgrepa[dd] lma lo[adview] lop[en] lua m[ove] mes[sages] mod[e] nbs[tart] nor omapc[lear] packl[oadall] popu[p] profd[el] ptf[irst] pts[elect] py3f[ile] pyx r[ead] redrawt[abline] ri[ght] rundo sIl sal[l] sbf[irst] sc scp se[t] sg sgn sie sip sme snoremenu spelli[nfo] spr[evious] sri star[tinsert] sts[elect] sus[pend] syncbind tabN[ext] tabl[ast] tabr[ewind] tcld[o] tj[ump] tlu tno[remap] tu[nmenu] undol[ist] v vie[w] vne[w] win[size] wq xmapc[lear] xr[estore] +syn keyword vimCommand contained ab arga[dd] argu[ment] bad[d] bm[odified] breaka[dd] bun[load] cabc[lear] cal[l] cc cf[ile] changes cla[st] cnew[er] com cope[n] cscope debug delep dell diffg[et] dig[raphs] do dsp[lit] echoe[rr] em[enu] endfo[r] eval f[ile] fina[lly] foldd[oopen] gr[ep] helpc[lose] his[tory] ij[ump] inor j[oin] keepj[umps] lab[ove] lat lc[d] le[ft] lfir[st] lh[elpgrep] lmak[e] loadk lp[revious] luado ma[rk] mk[exrc] mz[scheme] new nore on[ly] pc[lose] pp[op] promptf[ind] ptj[ump] pu[t] py[thon] pyxdo rec[over] reg[isters] rightb[elow] rv[iminfo] sIn san[dbox] sbl[ast] scI scr[iptnames] setf[iletype] sgI sgp sig sir smenu so[urce] spellr[are] sr srl startg[replace] substitutepattern sv[iew] syntime tabc[lose] tabm[ove] tabs tclf[ile] tl[ast] tlunmenu to[pleft] tunma[p] unh[ide] var vim9[cmd] vs[plit] winc[md] wqa[ll] xme xunme +syn keyword vimCommand contained abc[lear] argd[elete] as[cii] balt bn[ext] breakd[el] bw[ipeout] cabo[ve] cat[ch] ccl[ose] cfdo chd[ir] class cnf[ile] comc[lear] cp[revious] cstag debugg[reedy] deletel delm[arks] diffo[ff] dir doau e[dit] echom[sg] en[dif] endinterface ex files fini[sh] folddoc[losed] grepa[dd] helpf[ind] hor[izontal] il[ist] interface ju[mps] keepp[atterns] lad[dexpr] later lch[dir] lefta[bove] lg[etfile] lhi[story] lmapc[lear] loadkeymap lpf[ile] luafile mak[e] mks[ession] mzf[ile] nmapc[lear] nos[wapfile] opt[ions] pe[rl] pre[serve] promptr[epl] ptl[ast] pw[d] pydo pyxfile red[o] res[ize] ru[ntime] sI sIp sav[eas] sbm[odified] sce scripte[ncoding] setg[lobal] sgc sgr sign sl[eep] smile sor[t] spellr[epall] srI srn startr[eplace] substituterepeat sw[apname] t tabd[o] tabn[ext] tags te[aroff] tlm tm[enu] tp[revious] type unl ve[rsion] vim9s[cript] wN[ext] windo wundo xmenu xunmenu +syn keyword vimCommand contained abo[veleft] argded[upe] au bd[elete] bo[tright] breakl[ist] cN[ext] cad[dbuffer] cb[uffer] cd cfir[st] che[ckpath] cle[arjumps] cnor comp[iler] cpf[ile] cun def deletep delp diffp[atch] disa[ssemble] doaut ea echon endclass endt[ry] exi[t] filet fir[st] foldo[pen] gui helpg[rep] i imapc[lear] intro k lN[ext] laddb[uffer] lb[uffer] lcl[ose] leg[acy] lgetb[uffer] ll lne[xt] loc[kmarks] lr[ewind] lv[imgrep] marks mksp[ell] n[ext] noa nu[mber] ownsyntax ped[it] prev[ious] ps[earch] ptn[ext] py3 pyf[ile] q[uit] redi[r] ret[ab] rub[y] sIc sIr sbN[ext] sbn[ext] scg scriptv[ersion] setl[ocal] sge sh[ell] sil[ent] sla[st] sn[ext] sp[lit] spellr[rare] src srp static sun[hide] sy tN[ext] tabe[dit] tabnew tc[d] ter[minal] tlmenu tma[p] tr[ewind] u[ndo] unlo[ckvar] verb[ose] vim[grep] w[rite] winp[os] wv[iminfo] xnoreme xwininfo +syn keyword vimCommand contained abstract argdo bN[ext] bel[owright] bp[revious] bro[wse] cNf[ile] cadde[xpr] cbe[fore] cdo cg[etfile] checkt[ime] clo[se] co[py] con[tinue] cq[uit] cuna[bbrev] defc[ompile] deletl dep diffpu[t] dj[ump] dp earlier echow[indow] enddef endw[hile] exp filetype fix[del] for gvim helpt[ags] ia imp is[earch] kee[pmarks] lNf[ile] laddf[ile] lbe[fore] lcs lex[pr] lgete[xpr] lla[st] lnew[er] lockv[ar] ls lvimgrepa[dd] mat[ch] mkv[imrc] nb[key] noautocmd o[pen] p[rint] perld[o] pro ptN[ext] ptp[revious] py3do python3 qa[ll] redr[aw] retu[rn] rubyd[o] sIe sN[ext] sb[uffer] sbp[revious] sci scs sf[ind] sgi si sim[alt] sm[agic] sno[magic] spe[llgood] spellu[ndo] sre[wind] st[op] stj[ump] sunme syn ta[g] tabf[ind] tabo[nly] tch[dir] tf[irst] tln tmapc[lear] try una[bbreviate] uns[ilent] vert[ical] vimgrepa[dd] wa[ll] wn[ext] x[it] xnoremenu y[ank] +syn keyword vimCommand contained addd arge[dit] b[uffer] bf[irst] br[ewind] bufdo c[hange] caddf[ile] cbel[ow] ce[nter] cgetb[uffer] chi[story] cmapc[lear] col[der] conf[irm] cr[ewind] cw[indow] delc[ommand] deletp di[splay] diffs[plit] dl dr[op] ec el[se] endenum ene[w] export filt[er] fo[ld] fu[nction] h[elp] hi iabc[lear] import isp[lit] keepa l[ist] laf[ter] lbel[ow] lcscope lf[ile] lgr[ep] lli[st] lnf[ile] lol[der] lt[ag] lw[indow] menut[ranslate] mkvie[w] nbc[lose] noh[lsearch] ol[dfiles] pa[ckadd] po[p] prof[ile] pta[g] ptr[ewind] py3f[ile] pythonx quita[ll] redraws[tatus] rew[ind] rubyf[ile] sIg sa[rgument] sba[ll] sbr[ewind] scl scscope sfir[st] sgl sic sin sm[ap] snoreme spelld[ump] spellw[rong] srg sta[g] stopi[nsert] sunmenu sync tab tabfir[st] tabp[revious] tcl th[row] tlnoremenu tn[ext] ts[elect] undoj[oin] up[date] vi[sual] viu[sage] wh[ile] wp[revious] xa[ll] xprop z[^.=] +syn keyword vimCommand contained al[l] argg[lobal] syn match vimCommand contained "\" syn keyword vimStdPlugin contained Arguments Asm Break Cfilter Clear Continue DiffOrig Evaluate Finish Gdb Lfilter Man N[ext] Over P[rint] Program Run S Source Step Stop Termdebug TermdebugCommand TOhtml Until Winbar XMLent XMLns @@ -73,17 +74,17 @@ syn keyword vimAutoEvent contained BufCreate BufEnter BufFilePre BufLeave BufNew syn keyword vimGroup contained Comment Constant String Character Number Boolean Float Identifier Function Statement Conditional Repeat Label Operator Keyword Exception PreProc Include Define Macro PreCondit Type StorageClass Structure Typedef Special SpecialChar Tag Delimiter SpecialComment Debug Underlined Ignore Error Todo " Default highlighting groups {{{2 -syn keyword vimHLGroup contained ColorColumn CurSearch Cursor CursorColumn CursorIM CursorLine CursorLineFold CursorLineNr CursorLineSign DiffAdd DiffChange DiffDelete DiffText Directory EndOfBuffer ErrorMsg FoldColumn Folded IncSearch LineNr LineNrAbove LineNrBelow MatchParen Menu ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question QuickFixLine Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC StatusLineTerm StatusLineTermNC TabLine TabLineFill TabLineSel Terminal Title Tooltip VertSplit Visual VisualNOS WarningMsg WildMenu +syn keyword vimHLGroup contained ColorColumn CurSearch Cursor CursorColumn CursorIM CursorLine CursorLineFold CursorLineNr CursorLineSign DiffAdd DiffChange DiffDelete DiffText Directory EndOfBuffer ErrorMsg FoldColumn Folded IncSearch LineNr LineNrAbove LineNrBelow MatchParen Menu MessageWindow ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question QuickFixLine Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC StatusLineTerm StatusLineTermNC TabLine TabLineFill TabLineSel Terminal Title Tooltip VertSplit Visual VisualNOS WarningMsg WildMenu syn match vimHLGroup contained "Conceal" syn case match " Function Names {{{2 -syn keyword vimFuncName contained abs argc assert_equal assert_match atan balloon_show bufexists bufwinid ceil ch_canread ch_getbufnr ch_read ch_status complete_check count deletebufline digraph_set eval exists_compiled extendnew findfile fnameescape foldtextresult get getcharmod getcmdpos getcursorcharpos getftime getmarklist getreg gettagstack getwinvar haslocaldir hlexists indent inputrestore isabsolutepath job_getchannel join keys line2byte listener_flush luaeval mapnew matcharg matchlist min nr2char popup_beval popup_filter_menu popup_getpos popup_move pow prompt_setinterrupt prop_find prop_type_delete py3eval readblob reg_executing remote_expr remote_startserver reverse screenchars search searchpos setcellwidths setenv setpos settagstack sign_define sign_placelist sin soundfold spellsuggest str2float strchars string strtrans swapname synstack tabpagewinnr tempname term_getansicolors term_getscrolled terminalprops term_setapi term_wait test_garbagecollect_soon test_null_channel test_null_partial test_setmouse timer_info tolower type values winbufnr win_getid win_id2win winnr win_splitmove -syn keyword vimFuncName contained acos argidx assert_equalfile assert_nobeep atan2 balloon_split buflisted bufwinnr changenr ch_close ch_getjob ch_readblob cindent complete_info cscope_connection did_filetype digraph_setlist eventhandler exp feedkeys flatten fnamemodify foreground getbufinfo getcharpos getcmdscreenpos getcwd getftype getmatches getreginfo gettext glob hasmapto hlget index inputsave isdirectory job_info js_decode len lispindent listener_remove map mapset matchdelete matchstr mkdir or popup_clear popup_filter_yesno popup_hide popup_notification prevnonblank prompt_setprompt prop_list prop_type_get pyeval readdir reg_recording remote_foreground remove round screencol searchcount server2client setcharpos setfperm setqflist setwinvar sign_getdefined sign_undefine sinh sound_playevent split str2list strdisplaywidth strlen strwidth synconcealed system tagfiles term_dumpdiff term_getattr term_getsize term_list term_setkill test_alloc_fail test_getvalue test_null_dict test_null_string test_settime timer_pause toupper typename virtcol wincol win_gettype winlayout winrestcmd winwidth -syn keyword vimFuncName contained add arglistid assert_exception assert_notequal autocmd_add blob2list bufload byte2line char2nr ch_close_in ch_info ch_readraw clearmatches confirm cursor diff_filler echoraw executable expand filereadable flattennew foldclosed fullcommand getbufline getcharsearch getcmdtype getenv getimstatus getmousepos getregtype getwininfo glob2regpat histadd hlID indexof inputsecret isinf job_setoptions js_encode libcall list2blob localtime maparg match matchend matchstrpos mode pathshorten popup_close popup_findinfo popup_list popup_setoptions printf prop_add prop_remove prop_type_list pyxeval readdirex reltime remote_peek rename rubyeval screenpos searchdecl serverlist setcharsearch setline setreg sha256 sign_getplaced sign_unplace slice sound_playfile sqrt str2nr strftime strpart submatch synID systemlist taglist term_dumpload term_getcursor term_getstatus term_scrape term_setrestore test_autochdir test_gui_event test_null_function test_option_not_set test_srand_seed timer_start tr undofile virtcol2col windowsversion win_gotoid winline winrestview wordcount -syn keyword vimFuncName contained and argv assert_fails assert_notmatch autocmd_delete browse bufloaded byteidx charclass chdir ch_log ch_sendexpr col copy debugbreak diff_hlID empty execute expandcmd filewritable float2nr foldclosedend funcref getbufvar getcharstr getcmdwintype getfontname getjumplist getpid gettabinfo getwinpos globpath histdel hlset input insert islocked job_start json_decode libcallnr list2str log mapcheck matchadd matchfuzzy max mzeval perleval popup_create popup_findpreview popup_locate popup_settext prompt_getprompt prop_add_list prop_type_add pum_getpos rand readfile reltimefloat remote_read repeat screenattr screenrow searchpair setbufline setcmdpos setloclist settabvar shellescape sign_jump sign_unplacelist sort sound_stop srand strcharlen strgetchar strptime substitute synIDattr tabpagebuflist tan term_dumpwrite term_getjob term_gettitle term_sendkeys term_setsize test_feedinput test_ignore_error test_null_job test_override test_unknown timer_stop trim undotree visualmode win_execute winheight win_move_separator winsaveview writefile -syn keyword vimFuncName contained append asin assert_false assert_report autocmd_get browsedir bufname byteidxcomp charcol ch_evalexpr ch_logfile ch_sendraw complete cos deepcopy digraph_get environ exepath expr10 filter floor foldlevel function getchangelist getcmdcompltype getcompletion getfperm getline getpos gettabvar getwinposx has histget hostname inputdialog interrupt isnan job_status json_encode line listener_add log10 maplist matchaddpos matchfuzzypos menu_info nextnonblank popup_atcursor popup_dialog popup_getoptions popup_menu popup_show prompt_setcallback prop_clear prop_type_change pumvisible range reduce reltimestr remote_send resolve screenchar screenstring searchpairpos setbufvar setcursorcharpos setmatches settabwinvar shiftwidth sign_place simplify sound_clear spellbadword state strcharpart stridx strridx swapinfo synIDtrans tabpagenr tanh term_getaltscreen term_getline term_gettty term_setansicolors term_start test_garbagecollect_now test_null_blob test_null_list test_refcount test_void timer_stopall trunc uniq wildmenumode win_findbuf win_id2tabwin win_move_statusline win_screenpos xor -syn keyword vimFuncName contained appendbufline assert_beeps assert_inrange assert_true balloon_gettext bufadd bufnr call charidx ch_evalraw ch_open ch_setoptions complete_add cosh delete digraph_getlist escape exists extend finddir fmod foldtext garbagecollect getchar getcmdline getcurpos getfsize getloclist getqflist gettabwinvar getwinposy has_key histnr iconv inputlist invert items job_stop +syn keyword vimFuncName contained abs argc assert_equal assert_match atan balloon_show bufexists bufwinid ceil ch_canread ch_getbufnr ch_read ch_status complete_check count deletebufline digraph_set eval exists_compiled extendnew findfile fnameescape foldtextresult get getcharmod getcmdpos getcursorcharpos getftime getmarklist getreg gettabwinvar getwinposy has_key histnr iconv inputlist invert items job_stop keys lispindent listener_remove map mapset matchdelete matchstr mkdir or popup_clear popup_filter_yesno popup_hide popup_notification prevnonblank prompt_setprompt prop_list prop_type_get pyeval readdir reg_recording remote_foreground remove round screencol searchcount server2client setcharpos setenv setpos settagstack sign_define sign_placelist sin soundfold spellsuggest str2float strchars string strtrans swapname synstack tabpagewinnr tempname term_getansicolors term_getscrolled terminalprops term_setapi term_wait test_garbagecollect_soon test_null_channel test_null_partial test_setmouse timer_info tolower type values winbufnr win_getid win_id2win winnr win_splitmove +syn keyword vimFuncName contained acos argidx assert_equalfile assert_nobeep atan2 balloon_split buflisted bufwinnr changenr ch_close ch_getjob ch_readblob cindent complete_info cscope_connection did_filetype digraph_setlist eventhandler exp feedkeys flatten fnamemodify foreground getbufinfo getcharpos getcmdscreenpos getcwd getftype getmatches getreginfo gettagstack getwinvar haslocaldir hlexists indent inputrestore isabsolutepath job_getchannel join len list2blob localtime maparg match matchend matchstrpos mode pathshorten popup_close popup_findinfo popup_list popup_setoptions printf prop_add prop_remove prop_type_list pyxeval readdirex reltime remote_peek rename rubyeval screenpos searchdecl serverlist setcharsearch setfperm setqflist setwinvar sign_getdefined sign_undefine sinh sound_playevent split str2list strdisplaywidth strlen strwidth synconcealed system tagfiles term_dumpdiff term_getattr term_getsize term_list term_setkill test_alloc_fail test_getvalue test_null_dict test_null_string test_settime timer_pause toupper typename virtcol wincol win_gettype winlayout winrestcmd winwidth +syn keyword vimFuncName contained add arglistid assert_exception assert_notequal autocmd_add blob2list bufload byte2line char2nr ch_close_in ch_info ch_readraw clearmatches confirm cursor diff_filler echoraw executable expand filereadable flattennew foldclosed fullcommand getbufline getcharsearch getcmdtype getenv getimstatus getmousepos getregtype gettext glob hasmapto hlget index inputsave isdirectory job_info js_decode libcall list2str log mapcheck matchadd matchfuzzy max mzeval perleval popup_create popup_findpreview popup_locate popup_settext prompt_getprompt prop_add_list prop_type_add pum_getpos rand readfile reltimefloat remote_read repeat screenattr screenrow searchpair setbufline setcmdline setline setreg sha256 sign_getplaced sign_unplace slice sound_playfile sqrt str2nr strftime strpart submatch synID systemlist taglist term_dumpload term_getcursor term_getstatus term_scrape term_setrestore test_autochdir test_gui_event test_null_function test_option_not_set test_srand_seed timer_start tr undofile virtcol2col windowsversion win_gotoid winline winrestview wordcount +syn keyword vimFuncName contained and argv assert_fails assert_notmatch autocmd_delete browse bufloaded byteidx charclass chdir ch_log ch_sendexpr col copy debugbreak diff_hlID empty execute expandcmd filewritable float2nr foldclosedend funcref getbufvar getcharstr getcmdwintype getfontname getjumplist getpid getscriptinfo getwininfo glob2regpat histadd hlID indexof inputsecret isinf job_setoptions js_encode libcallnr listener_add log10 maplist matchaddpos matchfuzzypos menu_info nextnonblank popup_atcursor popup_dialog popup_getoptions popup_menu popup_show prompt_setcallback prop_clear prop_type_change pumvisible range reduce reltimestr remote_send resolve screenchar screenstring searchpairpos setbufvar setcmdpos setloclist settabvar shellescape sign_jump sign_unplacelist sort sound_stop srand strcharlen strgetchar strptime substitute synIDattr tabpagebuflist tan term_dumpwrite term_getjob term_gettitle term_sendkeys term_setsize test_feedinput test_ignore_error test_null_job test_override test_unknown timer_stop trim undotree visualmode win_execute winheight win_move_separator winsaveview writefile +syn keyword vimFuncName contained append asin assert_false assert_report autocmd_get browsedir bufname byteidxcomp charcol ch_evalexpr ch_logfile ch_sendraw complete cos deepcopy digraph_get environ exepath expr10 filter floor foldlevel function getchangelist getcmdcompltype getcompletion getfperm getline getpos gettabinfo getwinpos globpath histdel hlset input insert islocked job_start json_decode line listener_flush luaeval mapnew matcharg matchlist min nr2char popup_beval popup_filter_menu popup_getpos popup_move pow prompt_setinterrupt prop_find prop_type_delete py3eval readblob reg_executing remote_expr remote_startserver reverse screenchars search searchpos setcellwidths setcursorcharpos setmatches settabwinvar shiftwidth sign_place simplify sound_clear spellbadword state strcharpart stridx strridx swapinfo synIDtrans tabpagenr tanh term_getaltscreen term_getline term_gettty term_setansicolors term_start test_garbagecollect_now test_null_blob test_null_list test_refcount test_void timer_stopall trunc uniq wildmenumode win_findbuf win_id2tabwin win_move_statusline win_screenpos xor +syn keyword vimFuncName contained appendbufline assert_beeps assert_inrange assert_true balloon_gettext bufadd bufnr call charidx ch_evalraw ch_open ch_setoptions complete_add cosh delete digraph_getlist escape exists extend finddir fmod foldtext garbagecollect getchar getcmdline getcurpos getfsize getloclist getqflist gettabvar getwinposx has histget hostname inputdialog interrupt isnan job_status json_encode line2byte "--- syntax here and above generated by mkvimvim --- " Special Vim Highlighting (not automatic) {{{1 diff --git a/src/blob.c b/src/blob.c index 0d88c757aa..cfc3d372d3 100644 --- a/src/blob.c +++ b/src/blob.c @@ -667,11 +667,8 @@ blob_reduce( initial.vval.v_number = blob_get(b, 0); i = 1; } - else if (argvars[2].v_type != VAR_NUMBER) - { - emsg(_(e_number_expected)); + else if (check_for_number_arg(argvars, 2) == FAIL) return; - } else { initial = argvars[2]; diff --git a/src/change.c b/src/change.c index 53bd669ee5..c06991e882 100644 --- a/src/change.c +++ b/src/change.c @@ -362,6 +362,7 @@ invoke_listeners(buf_T *buf) int save_updating_screen = updating_screen; static int recursive = FALSE; listener_T *next; + listener_T *prev; if (buf->b_recorded_changes == NULL // nothing changed || buf->b_listener == NULL // no listeners @@ -406,10 +407,9 @@ invoke_listeners(buf_T *buf) } // If f_listener_remove() was called may have to remove a listener now. + prev = NULL; for (lnr = buf->b_listener; lnr != NULL; lnr = next) { - listener_T *prev = NULL; - next = lnr->lr_next; if (lnr->lr_id == 0) remove_listener(buf, lnr, prev); diff --git a/src/cmdexpand.c b/src/cmdexpand.c index 42f9c32658..8a7466076a 100644 --- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -3691,11 +3691,8 @@ f_getcompletion(typval_T *argvars, typval_T *rettv) return; pat = tv_get_string(&argvars[0]); - if (argvars[1].v_type != VAR_STRING) - { - semsg(_(e_invalid_argument_str), "type must be a string"); + if (check_for_string_arg(argvars, 1) == FAIL) return; - } type = tv_get_string(&argvars[1]); if (argvars[2].v_type != VAR_UNKNOWN) diff --git a/src/drawline.c b/src/drawline.c index 897017aba1..e9f0f51a1d 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -612,6 +612,8 @@ win_line( proptype_T *text_prop_type = NULL; int extra_for_textprop = FALSE; // wlv.n_extra set for textprop int text_prop_attr = 0; + int text_prop_attr_comb = 0; // text_prop_attr combined with + // syntax_attr int text_prop_id = 0; // active property ID int text_prop_flags = 0; int text_prop_follows = FALSE; // another text prop to display @@ -1676,7 +1678,7 @@ win_line( --pi; # ifdef FEAT_LINEBREAK // not exactly right but should work in most cases - if (in_linebreak && syntax_attr == text_prop_attr) + if (in_linebreak && syntax_attr == text_prop_attr_comb) syntax_attr = 0; # endif } @@ -1716,6 +1718,7 @@ win_line( if (wlv.n_extra == 0 || !extra_for_textprop) { text_prop_attr = 0; + text_prop_attr_comb = 0; text_prop_flags = 0; text_prop_type = NULL; text_prop_id = 0; @@ -1789,6 +1792,7 @@ win_line( saved_search_attr = search_attr; search_attr = 0; // restore when n_extra is zero text_prop_attr = 0; + text_prop_attr_comb = 0; if (*ptr == NUL) // don't combine char attr after EOL text_prop_flags &= ~PT_FLAG_COMBINE; @@ -1974,6 +1978,7 @@ win_line( syntax_attr = hl_combine_attr(syntax_attr, text_prop_attr); else syntax_attr = text_prop_attr; + text_prop_attr_comb = syntax_attr; } # endif #endif diff --git a/src/eval.c b/src/eval.c index f55d9de8ec..6b2d86b47a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -694,8 +694,15 @@ deref_function_name( { typval_T ref; char_u *name = *arg; + int save_flags = 0; ref.v_type = VAR_UNKNOWN; + if (evalarg != NULL) + { + // need to evaluate this to get an import, like in "a.Func" + save_flags = evalarg->eval_flags; + evalarg->eval_flags |= EVAL_EVALUATE; + } if (eval9(arg, &ref, evalarg, FALSE) == FAIL) { dictitem_T *v; @@ -703,7 +710,10 @@ deref_function_name( // If VarName was used it would not be found, try another way. v = find_var_also_in_script(name, NULL, FALSE); if (v == NULL) - return NULL; + { + name = NULL; + goto theend; + } copy_tv(&v->di_tv, &ref); } if (*skipwhite(*arg) != NUL) @@ -739,7 +749,11 @@ deref_function_name( semsg(_(e_not_callable_type_str), name); name = NULL; } + +theend: clear_tv(&ref); + if (evalarg != NULL) + evalarg->eval_flags = save_flags; return name; } @@ -4080,7 +4094,7 @@ eval9( // Handle following '[', '(' and '.' for expr[expr], expr.name, // expr(expr), expr->name(expr) if (ret == OK) - ret = handle_subscript(arg, name_start, rettv, evalarg, TRUE); + ret = handle_subscript(arg, name_start, rettv, evalarg, evaluate); /* * Apply logical NOT and unary '-', from right to left, ignore '+'. @@ -4349,7 +4363,7 @@ eval_method( rettv->v_type = VAR_UNKNOWN; name = *arg; - len = get_name_len(arg, &alias, evaluate, TRUE); + len = get_name_len(arg, &alias, evaluate, evaluate); if (alias != NULL) name = alias; @@ -6728,10 +6742,6 @@ ex_execute(exarg_T *eap) long start_lnum = SOURCING_LNUM; ga_init2(&ga, 1, 80); -#ifdef HAS_MESSAGE_WINDOW - if (eap->cmdidx == CMD_echowindow) - start_echowindow(); -#endif if (eap->skip) ++emsg_skip; @@ -6796,11 +6806,21 @@ ex_execute(exarg_T *eap) msg_sb_eol(); } - if (eap->cmdidx == CMD_echomsg || eap->cmdidx == CMD_echowindow) + if (eap->cmdidx == CMD_echomsg) { msg_attr(ga.ga_data, echo_attr); out_flush(); } + else if (eap->cmdidx == CMD_echowindow) + { +#ifdef HAS_MESSAGE_WINDOW + start_echowindow(); +#endif + msg_attr(ga.ga_data, echo_attr); +#ifdef HAS_MESSAGE_WINDOW + end_echowindow(); +#endif + } else if (eap->cmdidx == CMD_echoconsole) { ui_write(ga.ga_data, (int)STRLEN(ga.ga_data), TRUE); @@ -6832,10 +6852,6 @@ ex_execute(exarg_T *eap) if (eap->skip) --emsg_skip; -#ifdef HAS_MESSAGE_WINDOW - if (eap->cmdidx == CMD_echowindow) - end_echowindow(); -#endif set_nextcmd(eap, arg); } diff --git a/src/evalfunc.c b/src/evalfunc.c index 14cb770efe..88483fa8f0 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3607,17 +3607,13 @@ f_deepcopy(typval_T *argvars, typval_T *rettv) { varnumber_T noref = 0; - if (in_vim9script() - && (check_for_opt_bool_arg(argvars, 1) == FAIL)) + if (check_for_opt_bool_arg(argvars, 1) == FAIL) return; if (argvars[1].v_type != VAR_UNKNOWN) noref = tv_get_bool_chk(&argvars[1], NULL); - if (noref < 0 || noref > 1) - semsg(_(e_using_number_as_bool_nr), noref); - else - item_copy(&argvars[0], rettv, TRUE, TRUE, - noref == 0 ? get_copyID() : 0); + + item_copy(&argvars[0], rettv, TRUE, TRUE, noref == 0 ? get_copyID() : 0); } /* @@ -5257,21 +5253,11 @@ f_gettagstack(typval_T *argvars, typval_T *rettv) static void f_gettext(typval_T *argvars, typval_T *rettv) { - if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) + if (check_for_nonempty_string_arg(argvars, 0) == FAIL) return; - if (argvars[0].v_type != VAR_STRING - || argvars[0].vval.v_string == NULL - || *argvars[0].vval.v_string == NUL) - { - semsg(_(e_invalid_argument_str), tv_get_string(&argvars[0])); - } - else - { - rettv->v_type = VAR_STRING; - rettv->vval.v_string = vim_strsave( - (char_u *)_(argvars[0].vval.v_string)); - } + rettv->v_type = VAR_STRING; + rettv->vval.v_string = vim_strsave((char_u *)_(argvars[0].vval.v_string)); } // for VIM_VERSION_ defines @@ -5664,13 +5650,7 @@ f_has(typval_T *argvars, typval_T *rettv) 0 #endif }, - {"footer", -#ifdef FEAT_FOOTER - 1 -#else - 0 -#endif - }, + {"footer", 0}, {"fork", #if !defined(USE_SYSTEM) && defined(UNIX) 1 @@ -9676,7 +9656,9 @@ f_settagstack(typval_T *argvars, typval_T *rettv) // default is to replace the stack. if (argvars[2].v_type == VAR_UNKNOWN) action = 'r'; - else if (argvars[2].v_type == VAR_STRING) + else if (check_for_string_arg(argvars, 2) == FAIL) + return; + else { char_u *actstr; actstr = tv_get_string_chk(&argvars[2]); @@ -9691,11 +9673,6 @@ f_settagstack(typval_T *argvars, typval_T *rettv) return; } } - else - { - emsg(_(e_string_required)); - return; - } if (set_tagstack(wp, d, action) == OK) rettv->vval.v_number = 0; diff --git a/src/evalvars.c b/src/evalvars.c index 5a9c417c78..9661f91601 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -1091,7 +1091,6 @@ ex_let(exarg_T *eap) { // +=, /=, etc. require an existing variable semsg(_(e_cannot_use_operator_on_new_variable), eap->arg); - i = FAIL; } else if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL) { @@ -1114,7 +1113,6 @@ ex_let(exarg_T *eap) vim_strncpy(op, expr - len, len); semsg(_(e_white_space_required_before_and_after_str_at_str), op, argend); - i = FAIL; } if (eap->skip) @@ -4014,10 +4012,12 @@ var_wrong_func_name( { // Allow for w: b: s: and t:. In Vim9 script s: is not allowed, because // the name can be used without the s: prefix. + // Allow autoload variable. if (!((vim_strchr((char_u *)"wbt", name[0]) != NULL || (!in_vim9script() && name[0] == 's')) && name[1] == ':') && !ASCII_ISUPPER((name[0] != NUL && name[1] == ':') - ? name[2] : name[0])) + ? name[2] : name[0]) + && vim_strchr(name, '#') == NULL) { semsg(_(e_funcref_variable_name_must_start_with_capital_str), name); return TRUE; diff --git a/src/ex_cmdidxs.h b/src/ex_cmdidxs.h index 428253176f..70c4bc43b9 100644 --- a/src/ex_cmdidxs.h +++ b/src/ex_cmdidxs.h @@ -9,28 +9,28 @@ static const unsigned short cmdidxs1[26] = /* b */ 21, /* c */ 45, /* d */ 112, - /* e */ 137, - /* f */ 166, - /* g */ 183, - /* h */ 189, - /* i */ 199, - /* j */ 219, - /* k */ 221, - /* l */ 226, - /* m */ 289, - /* n */ 309, - /* o */ 329, - /* p */ 341, - /* q */ 380, - /* r */ 383, - /* s */ 403, - /* t */ 473, - /* u */ 519, - /* v */ 530, - /* w */ 551, - /* x */ 565, - /* y */ 575, - /* z */ 576 + /* e */ 138, + /* f */ 167, + /* g */ 184, + /* h */ 190, + /* i */ 200, + /* j */ 220, + /* k */ 222, + /* l */ 227, + /* m */ 290, + /* n */ 310, + /* o */ 330, + /* p */ 342, + /* q */ 381, + /* r */ 384, + /* s */ 404, + /* t */ 474, + /* u */ 520, + /* v */ 531, + /* w */ 552, + /* x */ 566, + /* y */ 576, + /* z */ 577 }; /* @@ -44,7 +44,7 @@ static const unsigned char cmdidxs2[26][26] = /* a */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 0, 0, 0, 8, 17, 0, 18, 0, 0, 0, 0, 0 }, /* b */ { 2, 0, 0, 5, 6, 8, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 0, 14, 0, 0, 0, 0, 23, 0, 0, 0 }, /* c */ { 3, 12, 16, 18, 20, 22, 25, 0, 0, 0, 0, 33, 38, 41, 47, 57, 59, 60, 61, 0, 63, 0, 66, 0, 0, 0 }, - /* d */ { 0, 0, 0, 0, 0, 0, 0, 0, 8, 18, 0, 19, 0, 0, 20, 0, 0, 22, 23, 0, 0, 0, 0, 0, 0, 0 }, + /* d */ { 0, 0, 0, 0, 0, 0, 0, 0, 9, 19, 0, 20, 0, 0, 21, 0, 0, 23, 24, 0, 0, 0, 0, 0, 0, 0 }, /* e */ { 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 9, 11, 12, 0, 0, 0, 0, 0, 0, 0, 23, 0, 24, 0, 0 }, /* f */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0 }, /* g */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 4, 5, 0, 0, 0, 0 }, @@ -69,4 +69,4 @@ static const unsigned char cmdidxs2[26][26] = /* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; -static const int command_count = 593; +static const int command_count = 594; diff --git a/src/ex_cmds.h b/src/ex_cmds.h index 94a2904924..c82595e38e 100644 --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -467,6 +467,9 @@ EXCMD(CMD_def, "def", ex_function, EXCMD(CMD_defcompile, "defcompile", ex_defcompile, EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_TRLBAR|EX_EXTRA, ADDR_NONE), +EXCMD(CMD_defer, "defer", ex_call, + EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK, + ADDR_NONE), EXCMD(CMD_delcommand, "delcommand", ex_delcommand, EX_NEEDARG|EX_WORD1|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK, ADDR_NONE), diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 7f7ea4bcbc..d54ab35a0c 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -1074,7 +1074,7 @@ do_cmdline( // Check for the next breakpoint at or after the ":while" // or ":for". - if (breakpoint != NULL) + if (breakpoint != NULL && lines_ga.ga_len > current_line) { *breakpoint = dbg_find_breakpoint( getline_equal(fgetline, cookie, getsourceline), diff --git a/src/ex_eval.c b/src/ex_eval.c index 61d288157d..2f31b3e1c5 100644 --- a/src/ex_eval.c +++ b/src/ex_eval.c @@ -925,7 +925,7 @@ cmd_is_name_only(char_u *arg) } else if (*p == '$') ++p; - get_name_len(&p, &alias, FALSE, FALSE); + (void)get_name_len(&p, &alias, FALSE, FALSE); } name_only = ends_excmd2(arg, skipwhite(p)); vim_free(alias); diff --git a/src/feature.h b/src/feature.h index a9dcdb0af3..08c00fc2ff 100644 --- a/src/feature.h +++ b/src/feature.h @@ -127,6 +127,8 @@ * Support was removed in 8.1.1093. * +farsi Farsi (Persian language) Keymap support. * Removed in patch 8.1.0932 + * +footer Motif only: Add a message area at the bottom of the + * main window area. */ /* @@ -1155,14 +1157,6 @@ # endif #endif -#if 0 -/* - * +footer Motif only: Add a message area at the bottom of the - * main window area. - */ -# define FEAT_FOOTER -#endif - /* * +autochdir 'autochdir' option. */ diff --git a/src/filepath.c b/src/filepath.c index a316a96abe..3094d91270 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -2232,6 +2232,7 @@ f_writefile(typval_T *argvars, typval_T *rettv) { int binary = FALSE; int append = FALSE; + int defer = FALSE; #ifdef HAVE_FSYNC int do_fsync = p_fs; #endif @@ -2285,6 +2286,8 @@ f_writefile(typval_T *argvars, typval_T *rettv) binary = TRUE; if (vim_strchr(arg2, 'a') != NULL) append = TRUE; + if (vim_strchr(arg2, 'D') != NULL) + defer = TRUE; #ifdef HAVE_FSYNC if (vim_strchr(arg2, 's') != NULL) do_fsync = TRUE; @@ -2297,37 +2300,59 @@ f_writefile(typval_T *argvars, typval_T *rettv) if (fname == NULL) return; + if (defer && !in_def_function() && get_current_funccal() == NULL) + { + semsg(_(e_str_not_inside_function), "defer"); + return; + } + // Always open the file in binary mode, library functions have a mind of // their own about CR-LF conversion. if (*fname == NUL || (fd = mch_fopen((char *)fname, append ? APPENDBIN : WRITEBIN)) == NULL) { - semsg(_(e_cant_create_file_str), *fname == NUL ? (char_u *)_("") : fname); + semsg(_(e_cant_create_file_str), + *fname == NUL ? (char_u *)_("") : fname); ret = -1; } - else if (blob) - { - if (write_blob(fd, blob) == FAIL) - ret = -1; -#ifdef HAVE_FSYNC - else if (do_fsync) - // Ignore the error, the user wouldn't know what to do about it. - // May happen for a device. - vim_ignored = vim_fsync(fileno(fd)); -#endif - fclose(fd); - } else { - if (write_list(fd, list, binary) == FAIL) - ret = -1; + if (defer) + { + typval_T tv; + + tv.v_type = VAR_STRING; + tv.v_lock = 0; + tv.vval.v_string = vim_strsave(fname); + if (tv.vval.v_string == NULL + || add_defer((char_u *)"delete", 1, &tv) == FAIL) + { + ret = -1; + fclose(fd); + (void)mch_remove(fname); + } + } + + if (ret == 0) + { + if (blob) + { + if (write_blob(fd, blob) == FAIL) + ret = -1; + } + else + { + if (write_list(fd, list, binary) == FAIL) + ret = -1; + } #ifdef HAVE_FSYNC - else if (do_fsync) - // Ignore the error, the user wouldn't know what to do about it. - // May happen for a device. - vim_ignored = vim_fsync(fileno(fd)); + if (ret == 0 && do_fsync) + // Ignore the error, the user wouldn't know what to do about + // it. May happen for a device. + vim_ignored = vim_fsync(fileno(fd)); #endif - fclose(fd); + fclose(fd); + } } rettv->vval.v_number = ret; @@ -3088,17 +3113,22 @@ expand_wildcards_eval( int ret = FAIL; char_u *eval_pat = NULL; char_u *exp_pat = *pat; - char *ignored_msg; + char *ignored_msg; int usedlen; + int is_cur_alt_file = *exp_pat == '%' || *exp_pat == '#'; + int star_follows = FALSE; - if (*exp_pat == '%' || *exp_pat == '#' || *exp_pat == '<') + if (is_cur_alt_file || *exp_pat == '<') { ++emsg_off; eval_pat = eval_vars(exp_pat, exp_pat, &usedlen, NULL, &ignored_msg, NULL, TRUE); --emsg_off; if (eval_pat != NULL) + { + star_follows = STRCMP(exp_pat + usedlen, "*") == 0; exp_pat = concat_str(eval_pat, exp_pat + usedlen); + } } if (exp_pat != NULL) @@ -3106,6 +3136,20 @@ expand_wildcards_eval( if (eval_pat != NULL) { + if (*num_file == 0 && is_cur_alt_file && star_follows) + { + // Expanding "%" or "#" and the file does not exist: Add the + // pattern anyway (without the star) so that this works for remote + // files and non-file buffer names. + *file = ALLOC_ONE(char_u *); + if (*file != NULL) + { + **file = eval_pat; + eval_pat = NULL; + *num_file = 1; + ret = OK; + } + } vim_free(exp_pat); vim_free(eval_pat); } diff --git a/src/float.c b/src/float.c index ef9b8309e0..aa7d697c6f 100644 --- a/src/float.c +++ b/src/float.c @@ -54,12 +54,11 @@ string2float( if (skip_quotes && vim_strchr((char_u *)s, '\'') != NULL) { char_u buf[100]; - char_u *p = buf; + char_u *p; int quotes = 0; vim_strncpy(buf, (char_u *)s, 99); - p = buf; - for (;;) + for (p = buf; ; p = skipdigits(p)) { // remove single quotes between digits, not in the exponent if (*p == '\'') @@ -69,7 +68,6 @@ string2float( } if (!vim_isdigit(*p)) break; - p = skipdigits(p); } s = (char *)buf; f = strtod(s, &s); diff --git a/src/gui.c b/src/gui.c index 75628d1ee3..0c7a4a1544 100644 --- a/src/gui.c +++ b/src/gui.c @@ -445,9 +445,6 @@ gui_init_check(void) #if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_HAIKU)) gui.toolbar_height = 0; #endif -#if defined(FEAT_FOOTER) && defined(FEAT_GUI_MOTIF) - gui.footer_height = 0; -#endif #ifdef FEAT_BEVAL_TIP gui.tooltip_fontset = NOFONTSET; #endif @@ -1551,10 +1548,6 @@ gui_get_base_height(void) if (gui_has_tabline()) base_height += gui.tabline_height; # endif -# ifdef FEAT_FOOTER - if (vim_strchr(p_go, GO_FOOTER) != NULL) - base_height += gui.footer_height; -# endif # if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) base_height += gui_mch_text_area_extra_height(); # endif @@ -3517,10 +3510,6 @@ gui_init_which_components(char_u *oldval UNUSED) #ifdef FEAT_GUI_TABLINE int using_tabline; #endif -#ifdef FEAT_FOOTER - static int prev_footer = -1; - int using_footer = FALSE; -#endif #if defined(FEAT_MENU) static int prev_tearoff = -1; int using_tearoff = FALSE; @@ -3594,11 +3583,6 @@ gui_init_which_components(char_u *oldval UNUSED) case GO_TOOLBAR: using_toolbar = TRUE; break; -#endif -#ifdef FEAT_FOOTER - case GO_FOOTER: - using_footer = TRUE; - break; #endif case GO_TEAROFF: #if defined(FEAT_MENU) @@ -3699,16 +3683,6 @@ gui_init_which_components(char_u *oldval UNUSED) fix_size = TRUE; } #endif -#ifdef FEAT_FOOTER - if (using_footer != prev_footer) - { - gui_mch_enable_footer(using_footer); - prev_footer = using_footer; - need_set_size |= RESIZE_VERT; - if (using_footer) - fix_size = TRUE; - } -#endif #if defined(FEAT_MENU) && !(defined(MSWIN) && !defined(FEAT_TEAROFF)) if (using_tearoff != prev_tearoff) { diff --git a/src/gui.h b/src/gui.h index 6a5cb1b9f5..2575245567 100644 --- a/src/gui.h +++ b/src/gui.h @@ -410,10 +410,6 @@ typedef struct Gui int tabline_height; #endif -#ifdef FEAT_FOOTER - int footer_height; // height of the message footer -#endif - #if defined(FEAT_TOOLBAR) \ && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_HAIKU) || defined(FEAT_GUI_MSWIN)) int toolbar_height; // height of the toolbar diff --git a/src/gui_motif.c b/src/gui_motif.c index 27c22d1b83..4c5ced5415 100644 --- a/src/gui_motif.c +++ b/src/gui_motif.c @@ -75,9 +75,6 @@ static Widget tabLine; static Widget tabLine_menu = 0; static int showing_tabline = 0; #endif -#ifdef FEAT_FOOTER -static Widget footer; -#endif #ifdef FEAT_MENU # if (XmVersion >= 1002) // remember the last set value for the tearoff item @@ -87,10 +84,6 @@ static Widget menuBar; #endif #ifdef FEAT_TOOLBAR -# ifdef FEAT_FOOTER -static void toolbarbutton_enter_cb(Widget, XtPointer, XEvent *, Boolean *); -static void toolbarbutton_leave_cb(Widget, XtPointer, XEvent *, Boolean *); -# endif static void reset_focus(void); #endif @@ -574,25 +567,6 @@ gui_x11_create_widgets(void) XmNshadowThickness, 0, NULL); -#ifdef FEAT_FOOTER - /* - * Create the Footer. - */ - footer = XtVaCreateWidget("footer", - xmLabelGadgetClass, vimForm, - XmNalignment, XmALIGNMENT_BEGINNING, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - XmNtraversalOn, False, - XmNrecomputeSize, False, - XmNleftAttachment, XmATTACH_FORM, - XmNleftOffset, 5, - XmNrightAttachment, XmATTACH_FORM, - XmNbottomAttachment, XmATTACH_FORM, - NULL); - gui_mch_set_footer((char_u *) ""); -#endif - /* * Install the callbacks. */ @@ -1315,12 +1289,6 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx) { XtAddCallback(menu->id, XmNactivateCallback, gui_x11_menu_cb, menu); -# ifdef FEAT_FOOTER - XtAddEventHandler(menu->id, EnterWindowMask, False, - toolbarbutton_enter_cb, menu); - XtAddEventHandler(menu->id, LeaveWindowMask, False, - toolbarbutton_leave_cb, menu); -# endif } } else @@ -2855,58 +2823,6 @@ gui_mch_dialog( } #endif // FEAT_GUI_DIALOG -#if defined(FEAT_FOOTER) || defined(PROTO) - - static int -gui_mch_compute_footer_height(void) -{ - Dimension height; // total Toolbar height - Dimension top; // XmNmarginTop - Dimension bottom; // XmNmarginBottom - Dimension shadow; // XmNshadowThickness - - XtVaGetValues(footer, - XmNheight, &height, - XmNmarginTop, &top, - XmNmarginBottom, &bottom, - XmNshadowThickness, &shadow, - NULL); - - return (int) height + top + bottom + (shadow << 1); -} - - void -gui_mch_enable_footer(int showit) -{ - if (showit) - { - gui.footer_height = gui_mch_compute_footer_height(); - XtManageChild(footer); - } - else - { - gui.footer_height = 0; - XtUnmanageChild(footer); - } - XtVaSetValues(textAreaForm, XmNbottomOffset, gui.footer_height, NULL); -} - - void -gui_mch_set_footer(char_u *s) -{ - XmString xms; - - xms = XmStringCreate((char *)s, STRING_TAG); - if (xms != NULL) - { - XtVaSetValues(footer, XmNlabelString, xms, NULL); - XmStringFree(xms); - } -} - -#endif - - #if defined(FEAT_TOOLBAR) || defined(PROTO) void gui_mch_show_toolbar(int showit) @@ -3131,39 +3047,6 @@ motif_get_toolbar_colors( XmNhighlightColor, hsp, NULL); } - -# ifdef FEAT_FOOTER -/* - * The next toolbar enter/leave callbacks should really do balloon help. But - * I have to use footer help for backwards compatibility. Hopefully both will - * get implemented and the user will have a choice. - */ - static void -toolbarbutton_enter_cb( - Widget w UNUSED, - XtPointer client_data, - XEvent *event UNUSED, - Boolean *cont UNUSED) -{ - vimmenu_T *menu = (vimmenu_T *) client_data; - - if (menu->strings[MENU_INDEX_TIP] != NULL) - { - if (vim_strchr(p_go, GO_FOOTER) != NULL) - gui_mch_set_footer(menu->strings[MENU_INDEX_TIP]); - } -} - - static void -toolbarbutton_leave_cb( - Widget w UNUSED, - XtPointer client_data UNUSED, - XEvent *event UNUSED, - Boolean *cont UNUSED) -{ - gui_mch_set_footer((char_u *) ""); -} -# endif #endif #if defined(FEAT_GUI_TABLINE) || defined(PROTO) diff --git a/src/highlight.c b/src/highlight.c index 7a08bf942d..b9a91afb8c 100644 --- a/src/highlight.c +++ b/src/highlight.c @@ -4515,7 +4515,7 @@ hlg_add_or_update(dict_T *dict) # endif p = add_attr_and_value(p, (char_u *)" guifg=", 7, guifg); p = add_attr_and_value(p, (char_u *)" guibg=", 7, guibg); - p = add_attr_and_value(p, (char_u *)" guisp=", 7, guisp); + (void)add_attr_and_value(p, (char_u *)" guisp=", 7, guisp); do_highlight(hlsetBuf, forceit, FALSE); diff --git a/src/indent.c b/src/indent.c index d7a2e550ad..134336c12d 100644 --- a/src/indent.c +++ b/src/indent.c @@ -998,7 +998,7 @@ get_breakindent_win( if (wp->w_briopt_list > 0) prev_list = wp->w_briopt_list; else - prev_list = (*regmatch.endp - *regmatch.startp); + prev_indent = (*regmatch.endp - *regmatch.startp); } vim_regfree(regmatch.regprog); } @@ -1017,13 +1017,8 @@ get_breakindent_win( bri += win_col_off2(wp); // add additional indent for numbered lists - if (wp->w_briopt_list != 0) - { - if (wp->w_briopt_list > 0) - bri += prev_list; - else - bri = prev_list; - } + if (wp->w_briopt_list > 0) + bri += prev_list; // indent minus the length of the showbreak string if (wp->w_briopt_sbr) diff --git a/src/insexpand.c b/src/insexpand.c index 08cbf5c068..bcaf77d8b9 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -3125,8 +3125,10 @@ get_complete_info(list_T *what_list, dict_T *retdict) ? compl_curr_match->cp_number - 1 : -1); } - // TODO - // if (ret == OK && (what_flag & CI_WHAT_INSERTED)) + if (ret == OK && (what_flag & CI_WHAT_INSERTED)) + { + // TODO + } } /* diff --git a/src/mbyte.c b/src/mbyte.c index 54f7fa4fbb..d3a4644bf7 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -5617,7 +5617,6 @@ f_setcellwidths(typval_T *argvars, typval_T *rettv UNUSED) } // Store the items in the new table. - item = 0; for (item = 0; item < l->lv_len; ++item) { listitem_T *lili = ptrs[item]; diff --git a/src/ops.c b/src/ops.c index 4733976527..88d85f8e0b 100644 --- a/src/ops.c +++ b/src/ops.c @@ -1282,11 +1282,11 @@ op_tilde(oparg_T *oap) #ifdef FEAT_NETBEANS_INTG if (netbeans_active() && one_change) { - char_u *ptr = ml_get_buf(curbuf, pos.lnum, FALSE); + char_u *ptr; netbeans_removed(curbuf, pos.lnum, bd.textcol, (long)bd.textlen); - // get the line again, it may have been flushed + // get the line now, it may have been flushed ptr = ml_get_buf(curbuf, pos.lnum, FALSE); netbeans_inserted(curbuf, pos.lnum, bd.textcol, &ptr[bd.textcol], bd.textlen); @@ -1344,7 +1344,6 @@ op_tilde(oparg_T *oap) pos.col = 0; pos.lnum++; } - ptr = ml_get_buf(curbuf, pos.lnum, FALSE); count = oap->end.col - pos.col + 1; netbeans_removed(curbuf, pos.lnum, pos.col, (long)count); // get the line again, it may have been flushed diff --git a/src/os_unix.c b/src/os_unix.c index 14f91f6bfb..c45c750b94 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4528,7 +4528,7 @@ mch_call_shell_terminal( // restore curwin/curbuf and a few other things aucmd_restbuf(&aco); - // only require pressing Enter when redrawing, to avoid that system() gets + // Only require pressing Enter when redrawing, to avoid that system() gets // the hit-enter prompt even though it didn't output anything. if (!RedrawingDisabled) wait_return(TRUE); @@ -5039,7 +5039,6 @@ mch_call_shell_fork( { // finished all the lines, close pipe close(toshell_fd); - toshell_fd = -1; break; } lp = ml_get(lnum); @@ -5421,7 +5420,7 @@ finished: * child already exited. */ if (wait_pid != pid) - wait_pid = wait4pid(pid, &status); + (void)wait4pid(pid, &status); # ifdef FEAT_GUI // Close slave side of pty. Only do this after the child has @@ -6517,7 +6516,7 @@ select_eintr: #ifdef FEAT_JOB_CHANNEL // also call when ret == 0, we may be polling a keep-open channel if (ret >= 0) - ret = channel_select_check(ret, &rfds, &wfds); + (void)channel_select_check(ret, &rfds, &wfds); #endif #endif // HAVE_SELECT diff --git a/src/popupwin.c b/src/popupwin.c index 8688f3e3d1..5f003803ba 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -2769,9 +2769,7 @@ f_popup_settext(typval_T *argvars, typval_T *rettv UNUSED) wp = find_popup_win(id); if (wp != NULL) { - if (argvars[1].v_type != VAR_STRING && argvars[1].v_type != VAR_LIST) - semsg(_(e_invalid_argument_str), tv_get_string(&argvars[1])); - else + if (check_for_string_or_list_arg(argvars, 1) != FAIL) { popup_set_buffer_text(wp->w_buffer, argvars[1]); redraw_win_later(wp, UPD_NOT_VALID); diff --git a/src/proto/userfunc.pro b/src/proto/userfunc.pro index 427d47b241..074a2b82a2 100644 --- a/src/proto/userfunc.pro +++ b/src/proto/userfunc.pro @@ -58,6 +58,8 @@ void func_ptr_unref(ufunc_T *fp); void func_ref(char_u *name); void func_ptr_ref(ufunc_T *fp); void ex_return(exarg_T *eap); +int add_defer(char_u *name, int argcount_arg, typval_T *argvars); +void handle_defer(void); void ex_call(exarg_T *eap); int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv); void discard_pending_return(void *rettv); diff --git a/src/proto/vim9cmds.pro b/src/proto/vim9cmds.pro index 7529d63d62..79a155780e 100644 --- a/src/proto/vim9cmds.pro +++ b/src/proto/vim9cmds.pro @@ -21,6 +21,8 @@ char_u *compile_finally(char_u *arg, cctx_T *cctx); char_u *compile_endtry(char_u *arg, cctx_T *cctx); char_u *compile_throw(char_u *arg, cctx_T *cctx); char_u *compile_eval(char_u *arg, cctx_T *cctx); +int get_defer_var_idx(cctx_T *cctx); +char_u *compile_defer(char_u *arg_start, cctx_T *cctx); char_u *compile_mult_expr(char_u *arg, int cmdidx, cctx_T *cctx); char_u *compile_put(char_u *arg, exarg_T *eap, cctx_T *cctx); char_u *compile_exec(char_u *line_arg, exarg_T *eap, cctx_T *cctx); diff --git a/src/proto/vim9execute.pro b/src/proto/vim9execute.pro index 80afb8536a..5203304cc7 100644 --- a/src/proto/vim9execute.pro +++ b/src/proto/vim9execute.pro @@ -3,6 +3,8 @@ void to_string_error(vartype_T vartype); void update_has_breakpoint(ufunc_T *ufunc); void funcstack_check_refcount(funcstack_T *funcstack); int set_ref_in_funcstacks(int copyID); +int in_def_function(void); +int add_defer_function(char_u *name, int argcount, typval_T *argvars); char_u *char_from_string(char_u *str, varnumber_T index); char_u *string_slice(char_u *str, varnumber_T first, varnumber_T last, int exclusive); int fill_partial_and_closure(partial_T *pt, ufunc_T *ufunc, ectx_T *ectx); diff --git a/src/proto/vim9expr.pro b/src/proto/vim9expr.pro index 233cfa2267..f58e346252 100644 --- a/src/proto/vim9expr.pro +++ b/src/proto/vim9expr.pro @@ -4,6 +4,7 @@ void clear_ppconst(ppconst_T *ppconst); int compile_member(int is_slice, int *keeping_dict, cctx_T *cctx); int compile_load_scriptvar(cctx_T *cctx, char_u *name, char_u *start, char_u **end); int compile_load(char_u **arg, char_u *end_arg, cctx_T *cctx, int is_expr, int error); +int compile_arguments(char_u **arg, cctx_T *cctx, int *argcount, ca_special_T special_fn); char_u *to_name_end(char_u *arg, int use_namespace); char_u *to_name_const_end(char_u *arg); int get_lambda_tv_and_compile(char_u **arg, typval_T *rettv, int types_optional, evalarg_T *evalarg); diff --git a/src/proto/vim9instr.pro b/src/proto/vim9instr.pro index 8a3254b9ee..b0f3aa4762 100644 --- a/src/proto/vim9instr.pro +++ b/src/proto/vim9instr.pro @@ -23,7 +23,7 @@ int generate_PUSHS(cctx_T *cctx, char_u **str); int generate_PUSHCHANNEL(cctx_T *cctx); int generate_PUSHJOB(cctx_T *cctx); int generate_PUSHBLOB(cctx_T *cctx, blob_T *blob); -int generate_PUSHFUNC(cctx_T *cctx, char_u *name, type_T *type); +int generate_PUSHFUNC(cctx_T *cctx, char_u *name, type_T *type, int may_prefix); int generate_AUTOLOAD(cctx_T *cctx, char_u *name, type_T *type); int generate_GETITEM(cctx_T *cctx, int index, int with_op); int generate_SLICE(cctx_T *cctx, int count); @@ -52,6 +52,7 @@ int generate_BLOBAPPEND(cctx_T *cctx); int generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount); int generate_UCALL(cctx_T *cctx, char_u *name, int argcount); int generate_PCALL(cctx_T *cctx, int argcount, char_u *name, type_T *type, int at_top); +int generate_DEFER(cctx_T *cctx, int var_idx, int argcount); int generate_STRINGMEMBER(cctx_T *cctx, char_u *name, size_t len); int generate_ECHO(cctx_T *cctx, int with_white, int count); int generate_MULT_EXPR(cctx_T *cctx, isntype_T isn_type, int count); diff --git a/src/sign.c b/src/sign.c index eaefd5f063..1073e6529a 100644 --- a/src/sign.c +++ b/src/sign.c @@ -2849,23 +2849,12 @@ f_sign_unplace(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = -1; - if (in_vim9script() - && (check_for_string_arg(argvars, 0) == FAIL + if ((check_for_string_arg(argvars, 0) == FAIL || check_for_opt_dict_arg(argvars, 1) == FAIL)) return; - if (argvars[0].v_type != VAR_STRING) - { - emsg(_(e_invalid_argument)); - return; - } - if (argvars[1].v_type != VAR_UNKNOWN) - { - if (check_for_dict_arg(argvars, 1) == FAIL) - return; dict = argvars[1].vval.v_dict; - } rettv->vval.v_number = sign_unplace_from_dict(&argvars[0], dict); } diff --git a/src/spellfile.c b/src/spellfile.c index 7620affee8..d650f870eb 100644 --- a/src/spellfile.c +++ b/src/spellfile.c @@ -404,7 +404,7 @@ spell_load_file( *
: */ for (i = 0; i < VIMSPELLMAGICL; ++i) - buf[i] = getc(fd); // + buf[i] = c = getc(fd); // if (STRNCMP(buf, VIMSPELLMAGIC, VIMSPELLMAGICL) != 0) { emsg(_(e_this_does_not_look_like_spell_file)); @@ -700,7 +700,7 @@ suggest_load_files(void) * : */ for (i = 0; i < VIMSUGMAGICL; ++i) - buf[i] = getc(fd); // + buf[i] = c = getc(fd); // if (STRNCMP(buf, VIMSUGMAGIC, VIMSUGMAGICL) != 0) { semsg(_(e_this_does_not_look_like_sug_file_str), @@ -841,13 +841,14 @@ read_cnt_string(FILE *fd, int cnt_bytes, int *cntp) read_region_section(FILE *fd, slang_T *lp, int len) { int i; + int c = 0; if (len > MAXREGIONS * 2) return SP_FORMERROR; for (i = 0; i < len; ++i) - lp->sl_regions[i] = getc(fd); // + lp->sl_regions[i] = c = getc(fd); // lp->sl_regions[len] = NUL; - return 0; + return c == EOF ? SP_TRUNCERROR : 0; } /* @@ -898,6 +899,7 @@ read_prefcond_section(FILE *fd, slang_T *lp) int cnt; int i; int n; + int c; char_u *p; char_u buf[MAXWLEN + 1]; @@ -925,7 +927,9 @@ read_prefcond_section(FILE *fd, slang_T *lp) buf[0] = '^'; // always match at one position only p = buf + 1; while (n-- > 0) - *p++ = getc(fd); // + *p++ = c = getc(fd); // + if (c == EOF) + break; *p = NUL; lp->sl_prefprog[i] = vim_regcomp(buf, RE_MAGIC + RE_STRING); } @@ -1063,7 +1067,7 @@ read_sal_section(FILE *fd, slang_T *slang) // store the char we got while checking for end of sm_lead *p++ = c; for (++i; i < ccnt; ++i) - *p++ = getc(fd); // + *p++ = c = getc(fd); // *p++ = NUL; // diff --git a/src/strings.c b/src/strings.c index 0313e7480e..55ee69ab11 100644 --- a/src/strings.c +++ b/src/strings.c @@ -960,11 +960,8 @@ string_reduce( return; p += STRLEN(rettv->vval.v_string); } - else if (argvars[2].v_type != VAR_STRING) - { - semsg(_(e_string_expected_for_argument_nr), 3); + else if (check_for_string_arg(argvars, 2) == FAIL) return; - } else copy_tv(&argvars[2], rettv); @@ -1047,21 +1044,11 @@ f_charidx(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = -1; - if (in_vim9script() - && (check_for_string_arg(argvars, 0) == FAIL + if ((check_for_string_arg(argvars, 0) == FAIL || check_for_number_arg(argvars, 1) == FAIL || check_for_opt_bool_arg(argvars, 2) == FAIL)) return; - if (argvars[0].v_type != VAR_STRING || argvars[1].v_type != VAR_NUMBER - || (argvars[2].v_type != VAR_UNKNOWN - && argvars[2].v_type != VAR_NUMBER - && argvars[2].v_type != VAR_BOOL)) - { - emsg(_(e_invalid_argument)); - return; - } - str = tv_get_string_chk(&argvars[0]); idx = tv_get_number_chk(&argvars[1], NULL); if (str == NULL || idx < 0) @@ -1783,11 +1770,8 @@ f_trim(typval_T *argvars, typval_T *rettv) if (head == NULL) return; - if (argvars[1].v_type != VAR_UNKNOWN && argvars[1].v_type != VAR_STRING) - { - semsg(_(e_invalid_argument_str), tv_get_string(&argvars[1])); + if (check_for_opt_string_arg(argvars, 1) == FAIL) return; - } if (argvars[1].v_type == VAR_STRING) { diff --git a/src/structs.h b/src/structs.h index 02589b4668..40d5046b28 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1753,6 +1753,7 @@ struct funccall_S linenr_T breakpoint; // next line with breakpoint or zero int dbg_tick; // debug_tick when breakpoint was set int level; // top nesting level of executed function + garray_T fc_defer; // functions to be called on return #ifdef FEAT_PROFILE proftime_T prof_child; // time spent in a child #endif @@ -1767,6 +1768,14 @@ struct funccall_S // "func" }; +// structure used as item in "fc_defer" +typedef struct +{ + char_u *dr_name; // function name, allocated + typval_T dr_argvars[MAX_FUNC_ARGS + 1]; + int dr_argcount; +} defer_T; + /* * Struct used by trans_function_name() */ @@ -2853,7 +2862,7 @@ struct file_buffer int b_u_synced; // entry lists are synced long b_u_seq_last; // last used undo sequence number long b_u_save_nr_last; // counter for last file write - long b_u_seq_cur; // hu_seq of header below which we are now + long b_u_seq_cur; // uh_seq of header below which we are now time_T b_u_time_cur; // uh_time of header below which we are now long b_u_save_nr_cur; // file write nr after which we are now diff --git a/src/tag.c b/src/tag.c index 3141e7686f..c3e23f624e 100644 --- a/src/tag.c +++ b/src/tag.c @@ -4368,7 +4368,12 @@ get_tags(list_T *list, char_u *pat, char_u *buf_fname) { for (i = 0; i < num_matches; ++i) { - parse_match(matches[i], &tp); + if (parse_match(matches[i], &tp) == FAIL) + { + vim_free(matches[i]); + continue; + } + is_static = test_for_static(&tp); // Skip pseudo-tag lines. @@ -4379,7 +4384,11 @@ get_tags(list_T *list, char_u *pat, char_u *buf_fname) } if ((dict = dict_alloc()) == NULL) + { ret = FAIL; + vim_free(matches[i]); + break; + } if (list_append_dict(list, dict) == FAIL) ret = FAIL; diff --git a/src/testdir/dumps/Test_echowin_eval.dump b/src/testdir/dumps/Test_echowin_eval.dump new file mode 100644 index 0000000000..80d5fc7c11 --- /dev/null +++ b/src/testdir/dumps/Test_echowin_eval.dump @@ -0,0 +1,8 @@ +> +0&#ffffff0@74 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|═+0#e000002&@74 +|t|e|s|t| @70 +|1+0#0000000&|2|3| @53|0|,|0|-|1| @8|A|l@1| diff --git a/src/testdir/dumps/Test_prop_linebreak.dump b/src/testdir/dumps/Test_prop_linebreak_1.dump similarity index 65% rename from src/testdir/dumps/Test_prop_linebreak.dump rename to src/testdir/dumps/Test_prop_linebreak_1.dump index 33be5b3122..c1a56e85e7 100644 --- a/src/testdir/dumps/Test_prop_linebreak.dump +++ b/src/testdir/dumps/Test_prop_linebreak_1.dump @@ -1,4 +1,4 @@ ->x+0&#ffffff0@49|]+0#ffffff16#e000002| +0#0000000#ffffff0@23 +>x+0&#ffffff0@49|]+0(ffff15| +0&#ffffff0@23 |x@69| @4 |~+0#4040ff13&| @73 |~| @73 diff --git a/src/testdir/dumps/Test_prop_linebreak_2.dump b/src/testdir/dumps/Test_prop_linebreak_2.dump new file mode 100644 index 0000000000..e705f71938 --- /dev/null +++ b/src/testdir/dumps/Test_prop_linebreak_2.dump @@ -0,0 +1,10 @@ +| +0#0000e05#a8a8a8255@1>x+0&#ffffff0@49|]+0(ffff15| +0#0000000#ffffff0@21 +| +0#0000e05#a8a8a8255@1|x+0&#ffffff0@69| +0#0000000&@2 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +| +0#0000000&@56|1|,|1| @10|A|l@1| diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim index 47dda72a70..7cd6d99fee 100644 --- a/src/testdir/runtest.vim +++ b/src/testdir/runtest.vim @@ -483,6 +483,7 @@ for g:testfunc in sort(s:tests) " A test can set g:test_is_flaky to retry running the test. let g:test_is_flaky = 0 + let starttime = strftime("%H:%M:%S") call RunTheTest(g:testfunc) " Repeat a flaky test. Give up when: @@ -493,10 +494,10 @@ for g:testfunc in sort(s:tests) \ && $TEST_NO_RETRY == '' \ && g:test_is_flaky while 1 - call add(s:messages, 'Found errors in ' . g:testfunc . ':') + call add(s:messages, 'Found errors in ' .. g:testfunc .. ':') call extend(s:messages, v:errors) - call add(total_errors, 'Run ' . g:run_nr . ':') + call add(total_errors, starttime .. ' Run ' .. g:run_nr .. ':') call extend(total_errors, v:errors) if g:run_nr >= 5 || prev_error == v:errors[0] @@ -516,6 +517,7 @@ for g:testfunc in sort(s:tests) let v:errors = [] let g:run_nr += 1 + let starttime = strftime("%H:%M:%S") call RunTheTest(g:testfunc) if len(v:errors) == 0 diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim index 0f0ffe878a..09d942f9a6 100644 --- a/src/testdir/shared.vim +++ b/src/testdir/shared.vim @@ -98,16 +98,16 @@ func RunServer(cmd, testfunc, args) try let g:currentJob = RunCommand(pycmd) - " Wait for up to 2 seconds for the port number to be there. + " Wait for some time for the port number to be there. let port = GetPort() if port == 0 - call assert_false(1, "Can't start " . a:cmd) + call assert_report(strftime("%H:%M:%S") .. " Can't start " .. a:cmd) return endif call call(function(a:testfunc), [port]) catch - call assert_false(1, 'Caught exception: "' . v:exception . '" in ' . v:throwpoint) + call assert_report('Caught exception: "' . v:exception . '" in ' . v:throwpoint) finally call s:kill_server(a:cmd) endtry diff --git a/src/testdir/test_arglist.vim b/src/testdir/test_arglist.vim index a7d707ca8e..2a46de06c1 100644 --- a/src/testdir/test_arglist.vim +++ b/src/testdir/test_arglist.vim @@ -97,7 +97,7 @@ endfunc func Test_argadd_empty_curbuf() new let curbuf = bufnr('%') - call writefile(['test', 'Xargadd'], 'Xargadd') + call writefile(['test', 'Xargadd'], 'Xargadd', 'D') " must not re-use the current buffer. argadd Xargadd call assert_equal(curbuf, bufnr('%')) @@ -108,7 +108,6 @@ func Test_argadd_empty_curbuf() call assert_equal('Xargadd', '%'->bufname()) call assert_equal(2, line('$')) - call delete('Xargadd') %argd bwipe! endfunc @@ -506,9 +505,9 @@ endfunc " Test for autocommand that redefines the argument list, when doing ":all". func Test_arglist_autocmd() autocmd BufReadPost Xxx2 next Xxx2 Xxx1 - call writefile(['test file Xxx1'], 'Xxx1') - call writefile(['test file Xxx2'], 'Xxx2') - call writefile(['test file Xxx3'], 'Xxx3') + call writefile(['test file Xxx1'], 'Xxx1', 'D') + call writefile(['test file Xxx2'], 'Xxx2', 'D') + call writefile(['test file Xxx3'], 'Xxx3', 'D') new " redefine arglist; go to Xxx1 @@ -524,18 +523,14 @@ func Test_arglist_autocmd() autocmd! BufReadPost Xxx2 enew! | only - call delete('Xxx1') - call delete('Xxx2') - call delete('Xxx3') argdelete Xxx* bwipe! Xxx1 Xxx2 Xxx3 endfunc func Test_arg_all_expand() - call writefile(['test file Xxx1'], 'Xx x') + call writefile(['test file Xxx1'], 'Xx x', 'D') next notexist Xx\ x runtest.vim call assert_equal('notexist Xx\ x runtest.vim', expand('##')) - call delete('Xx x') endfunc func Test_large_arg() diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim index 7c9d090b39..01e7718bb6 100644 --- a/src/testdir/test_assert.vim +++ b/src/testdir/test_assert.vim @@ -89,12 +89,12 @@ func Test_assert_equalfile() call remove(v:errors, 0) let goodtext = ["one", "two", "three"] - call writefile(goodtext, 'Xone') + call writefile(goodtext, 'Xone', 'D') call assert_equal(1, 'Xone'->assert_equalfile('xyzxyz')) call assert_match("E485: Can't read file xyzxyz", v:errors[0]) call remove(v:errors, 0) - call writefile(goodtext, 'Xtwo') + call writefile(goodtext, 'Xtwo', 'D') call assert_equal(0, assert_equalfile('Xone', 'Xtwo')) call writefile([goodtext[0]], 'Xone') @@ -124,9 +124,6 @@ func Test_assert_equalfile() call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message')) call assert_match("a message: difference at byte 234, line 1 after", v:errors[0]) call remove(v:errors, 0) - - call delete('Xone') - call delete('Xtwo') endfunc func Test_assert_notequal() @@ -368,7 +365,7 @@ func Test_override() eval 1->test_override('redraw') call test_override('ALL', 0) call assert_fails("call test_override('xxx', 1)", 'E475:') - call assert_fails("call test_override('redraw', 'yes')", 'E474:') + call assert_fails("call test_override('redraw', 'yes')", 'E1210:') endfunc func Test_mouse_position() diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index 2c7111e4ff..532f7b537b 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -24,12 +24,12 @@ endfunc " Test for the CursorHold autocmd func Test_CursorHold_autocmd() CheckRunVimInTerminal - call writefile(['one', 'two', 'three'], 'XoneTwoThree') + call writefile(['one', 'two', 'three'], 'XoneTwoThree', 'D') let before =<< trim END set updatetime=10 au CursorHold * call writefile([line('.')], 'XCHoutput', 'a') END - call writefile(before, 'XCHinit') + call writefile(before, 'XCHinit', 'D') let buf = RunVimInTerminal('-S XCHinit XoneTwoThree', {}) call term_sendkeys(buf, "G") call term_wait(buf, 50) @@ -44,9 +44,7 @@ func Test_CursorHold_autocmd() call WaitForAssert({-> assert_equal(['1', '2', '3'], readfile('XCHoutput')[-3:-1])}) call StopVimInTerminal(buf) - call delete('XCHinit') call delete('XCHoutput') - call delete('XoneTwoThree') endfunc if has('timers') @@ -124,7 +122,7 @@ if has('timers') augroup set_tabstop au OptionSet tabstop call timer_start(1, {-> execute("echo 'Handler called'", "")}) augroup END - call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline') + call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline', 'D') set modeline let v:errmsg = '' call assert_fails('split XoptionsetModeline', 'E12:') @@ -136,7 +134,6 @@ if has('timers') augroup END bwipe! set ts& - call delete('XoptionsetModeline') call test_override('starting', 0) endfunc @@ -246,8 +243,8 @@ endfunc func Test_autocmd_dummy_wipeout() " prepare files - call writefile([''], 'Xdummywipetest1.txt') - call writefile([''], 'Xdummywipetest2.txt') + call writefile([''], 'Xdummywipetest1.txt', 'D') + call writefile([''], 'Xdummywipetest2.txt', 'D') augroup test_bufunload_group autocmd! autocmd BufUnload * call add(s:li, "bufunload") @@ -261,8 +258,6 @@ func Test_autocmd_dummy_wipeout() call assert_equal(["bufunload", "bufwipeout"], s:li) bwipeout - call delete('Xdummywipetest1.txt') - call delete('Xdummywipetest2.txt') au! test_bufunload_group augroup! test_bufunload_group endfunc @@ -326,7 +321,7 @@ func Test_WinScrolled() au WinScrolled * let g:amatch = str2nr(expand('')) au WinScrolled * let g:afile = str2nr(expand('')) END - call writefile(lines, 'Xtest_winscrolled') + call writefile(lines, 'Xtest_winscrolled', 'D') let buf = RunVimInTerminal('-S Xtest_winscrolled', {'rows': 6}) call term_sendkeys(buf, ":echo g:scrolled\") @@ -361,7 +356,6 @@ func Test_WinScrolled() call WaitForAssert({-> assert_match('^v:true ', term_getline(buf, 6))}, 1000) call StopVimInTerminal(buf) - call delete('Xtest_winscrolled') endfunc func Test_WinScrolled_mouse() @@ -375,7 +369,7 @@ func Test_WinScrolled_mouse() let g:scrolled = 0 au WinScrolled * let g:scrolled += 1 END - call writefile(lines, 'Xtest_winscrolled_mouse') + call writefile(lines, 'Xtest_winscrolled_mouse', 'D') let buf = RunVimInTerminal('-S Xtest_winscrolled_mouse', {'rows': 10}) " With the upper split focused, send a scroll-down event to the unfocused one. @@ -392,7 +386,6 @@ func Test_WinScrolled_mouse() call WaitForAssert({-> assert_match('^2', term_getline(buf, 10))}, 1000) call StopVimInTerminal(buf) - call delete('Xtest_winscrolled_mouse') endfunc func Test_WinScrolled_close_curwin() @@ -405,7 +398,7 @@ func Test_WinScrolled_close_curwin() au WinScrolled * close au VimLeave * call writefile(['123456'], 'Xtestout') END - call writefile(lines, 'Xtest_winscrolled_close_curwin') + call writefile(lines, 'Xtest_winscrolled_close_curwin', 'D') let buf = RunVimInTerminal('-S Xtest_winscrolled_close_curwin', {'rows': 6}) " This was using freed memory @@ -415,7 +408,6 @@ func Test_WinScrolled_close_curwin() call assert_equal(['123456'], readfile('Xtestout')) - call delete('Xtest_winscrolled_close_curwin') call delete('Xtestout') endfunc @@ -431,7 +423,7 @@ func Test_WinScrolled_long_wrapped() call setline(1, repeat('foo', height * width)) call cursor(1, height * width) END - call writefile(lines, 'Xtest_winscrolled_long_wrapped') + call writefile(lines, 'Xtest_winscrolled_long_wrapped', 'D') let buf = RunVimInTerminal('-S Xtest_winscrolled_long_wrapped', {'rows': 6}) call term_sendkeys(buf, ":echo g:scrolled\") @@ -448,8 +440,6 @@ func Test_WinScrolled_long_wrapped() call term_sendkeys(buf, '$') call term_sendkeys(buf, ":echo g:scrolled\") call WaitForAssert({-> assert_match('^3 ', term_getline(buf, 6))}, 1000) - - call delete('Xtest_winscrolled_long_wrapped') endfunc func Test_WinClosed() @@ -772,13 +762,13 @@ func Test_autocmd_bufwipe_in_SessLoadPost() au VimLeave * call WriteErrors() [CODE] - call writefile(content, 'Xvimrc') + call writefile(content, 'Xvimrc', 'D') call system(GetVimCommand('Xvimrc') .. ' --not-a-term --noplugins -S Session.vim -c cq') let errors = join(readfile('Xerrors')) call assert_match('E814:', errors) set swapfile - for file in ['Session.vim', 'Xvimrc', 'Xerrors'] + for file in ['Session.vim', 'Xerrors'] call delete(file) endfor endfunc @@ -795,11 +785,10 @@ func Test_autocmd_blast_badd() qall [CODE] - call writefile(content, 'XblastBall') + call writefile(content, 'XblastBall', 'D') call system(GetVimCommand() .. ' --clean -S XblastBall') call assert_match('OK', readfile('Xerrors')->join()) - call delete('XblastBall') call delete('Xerrors') endfunc @@ -832,7 +821,7 @@ func Test_autocmd_bufwipe_in_SessLoadPost2() au VimLeave * call WriteErrors() [CODE] - call writefile(content, 'Xvimrc') + call writefile(content, 'Xvimrc', 'D') call system(GetVimCommand('Xvimrc') .. ' --not-a-term --noplugins -S Session.vim -c cq') let errors = join(readfile('Xerrors')) " This probably only ever matches on unix. @@ -840,7 +829,7 @@ func Test_autocmd_bufwipe_in_SessLoadPost2() call assert_match('SessionLoadPost DONE', errors) set swapfile - for file in ['Session.vim', 'Xvimrc', 'Xerrors'] + for file in ['Session.vim', 'Xerrors'] call delete(file) endfor endfunc @@ -1542,9 +1531,9 @@ endfunc func Test_Acmd_BufAll() enew! %bwipe! - call writefile(['Test file Xxx1'], 'Xxx1') - call writefile(['Test file Xxx2'], 'Xxx2') - call writefile(['Test file Xxx3'], 'Xxx3') + call writefile(['Test file Xxx1'], 'Xxx1', 'D') + call writefile(['Test file Xxx2'], 'Xxx2', 'D') + call writefile(['Test file Xxx3'], 'Xxx3', 'D') " Add three files to the buffer list split Xxx1 @@ -1566,9 +1555,6 @@ func Test_Acmd_BufAll() au! BufReadPost %bwipe! - call delete('Xxx1') - call delete('Xxx2') - call delete('Xxx3') enew! | only endfunc @@ -1578,11 +1564,11 @@ func Test_Acmd_BufEnter() %bwipe! call writefile(['start of test file Xxx1', \ "\this is a test", - \ 'end of test file Xxx1'], 'Xxx1') + \ 'end of test file Xxx1'], 'Xxx1', 'D') call writefile(['start of test file Xxx2', \ 'vim: set noai :', \ "\this is a test", - \ 'end of test file Xxx2'], 'Xxx2') + \ 'end of test file Xxx2'], 'Xxx2', 'D') au BufEnter Xxx2 brew set ai modeline modelines=3 @@ -1604,8 +1590,6 @@ func Test_Acmd_BufEnter() call assert_equal(4, line('.')) %bwipe! - call delete('Xxx1') - call delete('Xxx2') set ai&vim modeline&vim modelines&vim endfunc @@ -1632,8 +1616,8 @@ func Test_BufLeave_Wipe() let content = ['start of test file Xxx', \ 'this is a test', \ 'end of test file Xxx'] - call writefile(content, 'Xxx1') - call writefile(content, 'Xxx2') + call writefile(content, 'Xxx1', 'D') + call writefile(content, 'Xxx2', 'D') au BufLeave Xxx2 bwipe edit Xxx1 @@ -1659,8 +1643,6 @@ func Test_BufLeave_Wipe() let g:bufinfo = getbufinfo() call assert_equal(1, len(g:bufinfo)) - call delete('Xxx1') - call delete('Xxx2') call delete('test.out') %bwipe au! BufLeave @@ -1729,8 +1711,8 @@ func Test_BufWritePre() au BufWritePre Xxx1 bunload au BufWritePre Xxx2 bwipe - call writefile(['start of Xxx1', 'test', 'end of Xxx1'], 'Xxx1') - call writefile(['start of Xxx2', 'test', 'end of Xxx2'], 'Xxx2') + call writefile(['start of Xxx1', 'test', 'end of Xxx1'], 'Xxx1', 'D') + call writefile(['start of Xxx2', 'test', 'end of Xxx2'], 'Xxx2', 'D') edit Xtest e! Xxx2 @@ -1746,15 +1728,13 @@ func Test_BufWritePre() call assert_fails('w', 'E203:') call assert_equal('Xxx1', bufname('%')) au! BufWritePre - call delete('Xxx1') - call delete('Xxx2') endfunc " Test for BufUnload autocommand that unloads all the other buffers func Test_bufunload_all() let g:test_is_flaky = 1 - call writefile(['Test file Xxx1'], 'Xxx1')" - call writefile(['Test file Xxx2'], 'Xxx2')" + call writefile(['Test file Xxx1'], 'Xxx1', 'D')" + call writefile(['Test file Xxx2'], 'Xxx2', 'D')" let content =<< trim [CODE] func UnloadAllBufs() @@ -1773,15 +1753,12 @@ func Test_bufunload_all() q [CODE] - call writefile(content, 'Xtest') + call writefile(content, 'Xbunloadtest', 'D') call delete('Xout') - call system(GetVimCommandClean() .. ' -N --not-a-term -S Xtest') + call system(GetVimCommandClean() .. ' -N --not-a-term -S Xbunloadtest') call assert_true(filereadable('Xout')) - call delete('Xxx1') - call delete('Xxx2') - call delete('Xtest') call delete('Xout') endfunc @@ -1809,7 +1786,7 @@ endfunc " Test for "*Cmd" autocommands func Test_Cmd_Autocmds() - call writefile(['start of Xxx', "\tabc2", 'end of Xxx'], 'Xxx') + call writefile(['start of Xxx', "\tabc2", 'end of Xxx'], 'Xxx', 'D') enew! au BufReadCmd XtestA 0r Xxx|$del @@ -1884,7 +1861,6 @@ func Test_Cmd_Autocmds() au! FileWriteCmd au! FileAppendCmd %bwipe! - call delete('Xxx') enew! endfunc @@ -1909,7 +1885,7 @@ func Test_BufReadCmd() autocmd BufReadCmd *.test call s:ReadFile() autocmd BufWriteCmd *.test call s:WriteFile() - call writefile(['one', 'two', 'three'], 'Xcmd.test') + call writefile(['one', 'two', 'three'], 'Xcmd.test', 'D') edit Xcmd.test call assert_match('Xcmd.test" line 1 of 3', execute('file')) normal! Gofour @@ -1917,7 +1893,6 @@ func Test_BufReadCmd() call assert_equal(['one', 'two', 'three', 'four'], readfile('Xcmd.test')) bwipe! - call delete('Xcmd.test') au! BufReadCmd au! BufWriteCmd endfunc @@ -2324,7 +2299,7 @@ func Test_Changed_FirstTime() let g:test_is_flaky = 1 " Prepare file for TextChanged event. - call writefile([''], 'Xchanged.txt') + call writefile([''], 'Xchanged.txt', 'D') let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3}) call assert_equal('running', term_getstatus(buf)) " Wait for the ruler (in the status line) to be shown. @@ -2342,7 +2317,6 @@ func Test_Changed_FirstTime() call assert_equal([''], readfile('Xchanged.txt')) " clean up - call delete('Xchanged.txt') bwipe! endfunc @@ -2432,13 +2406,12 @@ func Test_autocmd_nested_switch_window() autocmd BufReadPost * autocmd SafeState * ++once foldclosed('.') autocmd WinEnter * matchadd('ErrorMsg', 'pat') END - call writefile(lines, 'Xautoscript') + call writefile(lines, 'Xautoscript', 'D') let buf = RunVimInTerminal('-S Xautoscript', {'rows': 10}) call VerifyScreenDump(buf, 'Test_autocmd_nested_switch', {}) call StopVimInTerminal(buf) call delete('Xautofile') - call delete('Xautoscript') endfunc func Test_autocmd_once() @@ -2590,7 +2563,7 @@ func Test_ReadWrite_Autocmds() au FileAppendPost *.out !cat Xtest.c >> test.out augroup END - call writefile(['/*', ' * Here is a new .c file', ' */'], 'Xtest.c') + call writefile(['/*', ' * Here is a new .c file', ' */'], 'Xtest.c', 'D') new foo.c " should load Xtest.c call assert_equal(['/*', ' * Here is a new .c file', ' */'], getline(2, 4)) w! >> test.out " append it to the output file @@ -2714,7 +2687,6 @@ func Test_ReadWrite_Autocmds() au! FileChangedShell call delete('Xtestfile.gz') - call delete('Xtest.c') call delete('test.out') endfunc @@ -2762,7 +2734,7 @@ func Test_autocmd_SafeState() call timer_start(10, {id -> execute('let g:again ..= "t"')}) endfunc END - call writefile(lines, 'XSafeState') + call writefile(lines, 'XSafeState', 'D') let buf = RunVimInTerminal('-S XSafeState', #{rows: 6}) " Sometimes we loop to handle a K_IGNORE, SafeState may be triggered once or @@ -2782,7 +2754,6 @@ func Test_autocmd_SafeState() call WaitForAssert({-> assert_match('xtx', term_getline(buf, 6))}, 1000) call StopVimInTerminal(buf) - call delete('XSafeState') endfunc func Test_autocmd_CmdWinEnter() @@ -3024,11 +2995,11 @@ func Test_BufReadPre_delfile() au! autocmd BufReadPre XbufreadPre call delete('XbufreadPre') augroup END - call writefile([], 'XbufreadPre') + call writefile([], 'XbufreadPre', 'D') call assert_fails('new XbufreadPre', 'E200:') call assert_equal('XbufreadPre', @%) call assert_equal(1, &readonly) - call delete('XbufreadPre') + augroup TestAuCmd au! augroup END @@ -3041,11 +3012,11 @@ func Test_BufReadPre_changebuf() au! autocmd BufReadPre Xchangebuf edit Xsomeotherfile augroup END - call writefile([], 'Xchangebuf') + call writefile([], 'Xchangebuf', 'D') call assert_fails('new Xchangebuf', 'E201:') call assert_equal('Xsomeotherfile', @%) call assert_equal(1, &readonly) - call delete('Xchangebuf') + augroup TestAuCmd au! augroup END @@ -3062,7 +3033,7 @@ func Test_BufDelete_changebuf() augroup END let save_cpo = &cpo set cpo+=f - call assert_fails('r Xfile', ['E812:', 'E484:']) + call assert_fails('r Xchangebuf', ['E812:', 'E484:']) call assert_equal('somefile', @%) let &cpo = save_cpo augroup TestAuCmd diff --git a/src/testdir/test_breakindent.vim b/src/testdir/test_breakindent.vim index 7163f25bd3..1c02294bc4 100644 --- a/src/testdir/test_breakindent.vim +++ b/src/testdir/test_breakindent.vim @@ -818,7 +818,7 @@ func Test_breakindent20_list() " check formatlistpat indent with different list level " showbreak and sbr - setl briopt=min:5,sbr,list:-1,shift:2 + setl briopt=min:5,sbr,list:-1 setl showbreak=> redraw! let expect = [ @@ -831,6 +831,44 @@ func Test_breakindent20_list() \ ] let lines = s:screen_lines2(1, 6, 20) call s:compare_lines(expect, lines) + + " check formatlistpat indent with different list level + " showbreak sbr and shift + setl briopt=min:5,sbr,list:-1,shift:2 + setl showbreak=> + redraw! + let expect = [ + \ "* Congress shall ", + \ "> make no law ", + \ "*** Congress shall ", + \ "> make no law ", + \ "**** Congress shall ", + \ "> make no law ", + \ ] + let lines = s:screen_lines2(1, 6, 20) + call s:compare_lines(expect, lines) + + " check breakindent works if breakindentopt=list:-1 + " for a non list content + %delete _ + call setline(1, [' Congress shall make no law', + \ ' Congress shall make no law', + \ ' Congress shall make no law']) + norm! 1gg + setl briopt=min:5,list:-1 + setl showbreak= + redraw! + let expect = [ + \ " Congress shall ", + \ " make no law ", + \ " Congress shall ", + \ " make no law ", + \ " Congress shall ", + \ " make no law ", + \ ] + let lines = s:screen_lines2(1, 6, 20) + call s:compare_lines(expect, lines) + call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&') endfunc diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index bec0f5fdf8..80e82eaeb0 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -605,7 +605,7 @@ func Test_getcompletion() call assert_fails("call getcompletion('\\\\@!\\\\@=', 'buffer')", 'E871:') call assert_fails('call getcompletion("", "burp")', 'E475:') - call assert_fails('call getcompletion("abc", [])', 'E475:') + call assert_fails('call getcompletion("abc", [])', 'E1174:') endfunc " Test for getcompletion() with "fuzzy" in 'wildoptions' @@ -1306,6 +1306,18 @@ func Test_cmdline_write_alternatefile() bw! endfunc +func Test_cmdline_expand_cur_alt_file() + enew + file http://some.com/file.txt + call feedkeys(":e %\\\"\", 'xt') + call assert_equal('"e http://some.com/file.txt', @:) + edit another + call feedkeys(":e #\\\"\", 'xt') + call assert_equal('"e http://some.com/file.txt', @:) + bwipe + bwipe http://some.com/file.txt +endfunc + " using a leading backslash here set cpo+=C diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim index 313d791850..3669cfd40b 100644 --- a/src/testdir/test_eval_stuff.vim +++ b/src/testdir/test_eval_stuff.vim @@ -1,6 +1,7 @@ " Tests for various eval things. source view_util.vim +source shared.vim function s:foo() abort try @@ -34,9 +35,9 @@ func Test_mkdir_p() call assert_report('mkdir(..., "p") failed for an existing directory') endtry " 'p' doesn't suppress real errors - call writefile([], 'Xfile') - call assert_fails('call mkdir("Xfile", "p")', 'E739:') - call delete('Xfile') + call writefile([], 'Xmkdirfile') + call assert_fails('call mkdir("Xmkdirfile", "p")', 'E739:') + call delete('Xmkdirfile') call delete('Xmkdir', 'rf') call assert_equal(0, mkdir(test_null_string())) call assert_fails('call mkdir([])', 'E730:') @@ -87,6 +88,18 @@ func Test_for_over_null_string() let &enc = save_enc endfunc +func Test_for_invalid_line_count() + let lines =<< trim END + 111111111111111111111111 for line in ['one'] + endfor + END + call writefile(lines, 'XinvalidFor') + " only test that this doesn't crash + call RunVim([], [], '-u NONE -e -s -S XinvalidFor -c qa') + + call delete('XinvalidFor') +endfunc + func Test_readfile_binary() new call setline(1, ['one', 'two', 'three']) diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim index 52d41db601..a56676ef5a 100644 --- a/src/testdir/test_excmd.vim +++ b/src/testdir/test_excmd.vim @@ -83,23 +83,23 @@ endfunc " Test for the :drop command func Test_drop_cmd() - call writefile(['L1', 'L2'], 'Xfile') + call writefile(['L1', 'L2'], 'Xdropfile') enew | only - drop Xfile + drop Xdropfile call assert_equal('L2', getline(2)) " Test for switching to an existing window below new - drop Xfile + drop Xdropfile call assert_equal(1, winnr()) " Test for splitting the current window enew | only set modified - drop Xfile + drop Xdropfile call assert_equal(2, winnr('$')) " Check for setting the argument list - call assert_equal(['Xfile'], argv()) + call assert_equal(['Xdropfile'], argv()) enew | only! - call delete('Xfile') + call delete('Xdropfile') endfunc " Test for the :append command @@ -509,10 +509,10 @@ func Test_redir_cmd_readonly() CheckNotRoot " Redirecting to a read-only file - call writefile([], 'Xfile') - call setfperm('Xfile', 'r--r--r--') - call assert_fails('redir! > Xfile', 'E190:') - call delete('Xfile') + call writefile([], 'Xredirfile') + call setfperm('Xredirfile', 'r--r--r--') + call assert_fails('redir! > Xredirfile', 'E190:') + call delete('Xredirfile') endfunc " Test for the :filetype command @@ -532,21 +532,21 @@ endfunc " Test for the :read command func Test_read_cmd() - call writefile(['one'], 'Xfile') + call writefile(['one'], 'Xcmdfile') new call assert_fails('read', 'E32:') - edit Xfile + edit Xcmdfile read call assert_equal(['one', 'one'], getline(1, '$')) close! new - read Xfile + read Xcmdfile call assert_equal(['', 'one'], getline(1, '$')) call deletebufline('', 1, '$') - call feedkeys("Qr Xfile\visual\", 'xt') + call feedkeys("Qr Xcmdfile\visual\", 'xt') call assert_equal(['one'], getline(1, '$')) close! - call delete('Xfile') + call delete('Xcmdfile') endfunc " Test for running Ex commands when text is locked. @@ -633,9 +633,9 @@ func Sandbox_tests() endif call assert_fails("let $TESTVAR=1", 'E48:') call assert_fails("call feedkeys('ivim')", 'E48:') - call assert_fails("source! Xfile", 'E48:') - call assert_fails("call delete('Xfile')", 'E48:') - call assert_fails("call writefile([], 'Xfile')", 'E48:') + call assert_fails("source! Xsomefile", 'E48:') + call assert_fails("call delete('Xthatfile')", 'E48:') + call assert_fails("call writefile([], 'Xanotherfile')", 'E48:') call assert_fails('!ls', 'E48:') call assert_fails('shell', 'E48:') call assert_fails('stop', 'E48:') @@ -660,7 +660,7 @@ func Sandbox_tests() if has('terminal') call assert_fails('terminal', 'E48:') call assert_fails('call term_start("vim")', 'E48:') - call assert_fails('call term_dumpwrite(1, "Xfile")', 'E48:') + call assert_fails('call term_dumpwrite(1, "Xdumpfile")', 'E48:') endif if has('channel') call assert_fails("call ch_logfile('chlog')", 'E48:') @@ -727,17 +727,17 @@ endfunc " Test :write after changing name with :file and loading it with :edit func Test_write_after_rename() - call writefile(['text'], 'Xfile') + call writefile(['text'], 'Xafterfile') enew - file Xfile + file Xafterfile call assert_fails('write', 'E13: File exists (add ! to override)') " works OK after ":edit" edit write - call delete('Xfile') + call delete('Xafterfile') bwipe! endfunc diff --git a/src/testdir/test_expand.vim b/src/testdir/test_expand.vim index cd537f4ea1..8f2fab69ea 100644 --- a/src/testdir/test_expand.vim +++ b/src/testdir/test_expand.vim @@ -57,26 +57,26 @@ func Test_expandcmd() unlet $FOO new - edit Xfile1 - call assert_equal('e Xfile1', expandcmd('e %')) - edit Xfile2 - edit Xfile1 - call assert_equal('e Xfile2', 'e #'->expandcmd()) - edit Xfile2 - edit Xfile3 - edit Xfile4 - let bnum = bufnr('Xfile2') - call assert_equal('e Xfile2', expandcmd('e #' . bnum)) + edit Xpandfile1 + call assert_equal('e Xpandfile1', expandcmd('e %')) + edit Xpandfile2 + edit Xpandfile1 + call assert_equal('e Xpandfile2', 'e #'->expandcmd()) + edit Xpandfile2 + edit Xpandfile3 + edit Xpandfile4 + let bnum = bufnr('Xpandfile2') + call assert_equal('e Xpandfile2', expandcmd('e #' . bnum)) call setline('.', 'Vim!@#') call assert_equal('e Vim', expandcmd('e ')) call assert_equal('e Vim!@#', expandcmd('e ')) enew! - edit Xfile.java - call assert_equal('e Xfile.py', expandcmd('e %:r.py')) + edit Xpandfile.java + call assert_equal('e Xpandfile.py', expandcmd('e %:r.py')) call assert_equal('make abc.java', expandcmd('make abc.%:e')) - call assert_equal('make Xabc.java', expandcmd('make %:s?file?abc?')) + call assert_equal('make Xabc.java', expandcmd('make %:s?pandfile?abc?')) edit a1a2a3.rb - call assert_equal('make b1b2b3.rb a1a2a3 Xfile.o', expandcmd('make %:gs?a?b? %< #<.o')) + call assert_equal('make b1b2b3.rb a1a2a3 Xpandfile.o', expandcmd('make %:gs?a?b? %< #<.o')) call assert_equal('make ', expandcmd("make ")) call assert_equal('make ', expandcmd("make ")) diff --git a/src/testdir/test_file_perm.vim b/src/testdir/test_file_perm.vim index 1cb09e8647..bb6573bab6 100644 --- a/src/testdir/test_file_perm.vim +++ b/src/testdir/test_file_perm.vim @@ -22,9 +22,9 @@ func Test_file_perm() call assert_equal(1, setfperm('Xtest', 'rwx------')) call delete('Xtest') - call assert_fails("call setfperm(['Xfile'], 'rw-rw-rw-')", 'E730:') - call assert_fails("call setfperm('Xfile', [])", 'E730:') - call assert_fails("call setfperm('Xfile', 'rwxrwxrwxrw')", 'E475:') + call assert_fails("call setfperm(['Xpermfile'], 'rw-rw-rw-')", 'E730:') + call assert_fails("call setfperm('Xpermfile', [])", 'E730:') + call assert_fails("call setfperm('Xpermfile', 'rwxrwxrwxrw')", 'E475:') endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_filechanged.vim b/src/testdir/test_filechanged.vim index 5dca43fd4e..5a9a400752 100644 --- a/src/testdir/test_filechanged.vim +++ b/src/testdir/test_filechanged.vim @@ -253,15 +253,15 @@ endfunc " Test for editing a new buffer from a FileChangedShell autocmd func Test_FileChangedShell_newbuf() - call writefile(['one', 'two'], 'Xfile') - new Xfile + call writefile(['one', 'two'], 'Xchfile') + new Xchfile augroup testnewbuf autocmd FileChangedShell * enew augroup END - call writefile(['red'], 'Xfile') + call writefile(['red'], 'Xchfile') call assert_fails('checktime', 'E811:') au! testnewbuf - call delete('Xfile') + call delete('Xchfile') endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_fileformat.vim b/src/testdir/test_fileformat.vim index 6ba6e49ada..1c66e882c8 100644 --- a/src/testdir/test_fileformat.vim +++ b/src/testdir/test_fileformat.vim @@ -22,16 +22,16 @@ endfunc func Test_fileformat_autocommand() let filecnt = ["", "foobar\", "eins\", "\", "zwei\", "drei", "vier", "fünf", ""] let ffs = &ffs - call writefile(filecnt, 'Xfile', 'b') - au BufReadPre Xfile set ffs=dos ff=dos - new Xfile + call writefile(filecnt, 'Xffafile', 'b') + au BufReadPre Xffafile set ffs=dos ff=dos + new Xffafile call assert_equal('dos', &l:ff) call assert_equal('dos', &ffs) " cleanup - call delete('Xfile') + call delete('Xffafile') let &ffs = ffs - au! BufReadPre Xfile + au! BufReadPre Xffafile bw! endfunc @@ -314,14 +314,14 @@ endfunc " used as the 'fileformat'. func Test_fileformat_on_startup() let after =<< trim END - call writefile([&fileformat], 'Xfile', 'a') + call writefile([&fileformat], 'Xonsfile', 'a') quit END call RunVim(["set ffs=dos,unix,mac"], after, '') call RunVim(["set ffs=mac,dos,unix"], after, '') call RunVim(["set ffs=unix,mac,dos"], after, '') - call assert_equal(['dos', 'mac', 'unix'], readfile('Xfile')) - call delete('Xfile') + call assert_equal(['dos', 'mac', 'unix'], readfile('Xonsfile')) + call delete('Xonsfile') endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index fbb8d2d2dd..551602fbe1 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -14,15 +14,15 @@ endfunc func Test_conf_type() filetype on - call writefile(['# some comment', 'must be conf'], 'Xfile') + call writefile(['# some comment', 'must be conf'], 'Xconffile') augroup filetypedetect au BufNewFile,BufRead * call assert_equal(0, did_filetype()) augroup END - split Xfile + split Xconffile call assert_equal('conf', &filetype) bwipe! - call delete('Xfile') + call delete('Xconffile') filetype off endfunc @@ -30,15 +30,15 @@ func Test_other_type() filetype on augroup filetypedetect au BufNewFile,BufRead * call assert_equal(0, did_filetype()) - au BufNewFile,BufRead Xfile setf testfile + au BufNewFile,BufRead Xotherfile setf testfile au BufNewFile,BufRead * call assert_equal(1, did_filetype()) augroup END - call writefile(['# some comment', 'must be conf'], 'Xfile') - split Xfile + call writefile(['# some comment', 'must be conf'], 'Xotherfile') + split Xotherfile call assert_equal('testfile', &filetype) bwipe! - call delete('Xfile') + call delete('Xotherfile') filetype off endfunc diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim index 2618084025..33303da1b2 100644 --- a/src/testdir/test_fold.vim +++ b/src/testdir/test_fold.vim @@ -137,9 +137,9 @@ func Test_indent_fold_with_read() call assert_equal(1, foldlevel(n)) endfor - call writefile(["a", "", "\a"], 'Xfile') + call writefile(["a", "", "\a"], 'Xinfofile') foldopen - 2read Xfile + 2read Xinfofile %foldclose call assert_equal(1, foldlevel(1)) call assert_equal(2, foldclosedend(1)) @@ -150,7 +150,7 @@ func Test_indent_fold_with_read() bwipe! set foldmethod& - call delete('Xfile') + call delete('Xinfofile') endfunc func Test_combining_folds_indent() @@ -216,8 +216,8 @@ func Test_update_folds_expr_read() set foldexpr=s:TestFoldExpr(v:lnum) 2 foldopen - call writefile(['b', 'b', 'a', 'a', 'd', 'a', 'a', 'c'], 'Xfile') - read Xfile + call writefile(['b', 'b', 'a', 'a', 'd', 'a', 'a', 'c'], 'Xupfofile') + read Xupfofile %foldclose call assert_equal(2, foldclosedend(1)) call assert_equal(0, foldlevel(3)) @@ -226,7 +226,7 @@ func Test_update_folds_expr_read() call assert_equal(10, foldclosedend(7)) call assert_equal(14, foldclosedend(11)) - call delete('Xfile') + call delete('Xupfofile') bwipe! set foldmethod& foldexpr& endfunc diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 43eb265d62..cad1d4b435 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -375,22 +375,22 @@ func Test_resolve_win32() " test for shortcut file if executable('cscript') - new Xfile + new Xresfile wq let lines =<< trim END Set fs = CreateObject("Scripting.FileSystemObject") Set ws = WScript.CreateObject("WScript.Shell") Set shortcut = ws.CreateShortcut("Xlink.lnk") - shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xfile") + shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xresfile") shortcut.Save END call writefile(lines, 'link.vbs') silent !cscript link.vbs call delete('link.vbs') - call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink.lnk'))) - call delete('Xfile') + call assert_equal(s:normalize_fname(getcwd() . '\Xresfile'), s:normalize_fname(resolve('./Xlink.lnk'))) + call delete('Xresfile') - call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink.lnk'))) + call assert_equal(s:normalize_fname(getcwd() . '\Xresfile'), s:normalize_fname(resolve('./Xlink.lnk'))) call delete('Xlink.lnk') else echomsg 'skipped test for shortcut file' @@ -399,20 +399,20 @@ func Test_resolve_win32() " remove files call delete('Xlink') call delete('Xdir', 'd') - call delete('Xfile') + call delete('Xresfile') " test for symbolic link to a file - new Xfile + new Xresfile wq - call assert_equal('Xfile', resolve('Xfile')) - silent !mklink Xlink Xfile + call assert_equal('Xresfile', resolve('Xresfile')) + silent !mklink Xlink Xresfile if !v:shell_error - call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink'))) + call assert_equal(s:normalize_fname(getcwd() . '\Xresfile'), s:normalize_fname(resolve('./Xlink'))) call delete('Xlink') else echomsg 'skipped test for symbolic link to a file' endif - call delete('Xfile') + call delete('Xresfile') " test for junction to a directory call mkdir('Xdir') @@ -447,9 +447,9 @@ func Test_resolve_win32() endif " test for buffer name - new Xfile + new Xbuffile wq - silent !mklink Xlink Xfile + silent !mklink Xlink Xbuffile if !v:shell_error edit Xlink call assert_equal('Xlink', bufname('%')) @@ -458,7 +458,7 @@ func Test_resolve_win32() else echomsg 'skipped test for buffer name' endif - call delete('Xfile') + call delete('Xbuffile') " test for reparse point call mkdir('Xdir') @@ -1247,11 +1247,11 @@ func Test_charidx() call assert_equal(-1, charidx(a, 8, 1)) call assert_equal(-1, charidx('', 0, 1)) - call assert_fails('let x = charidx([], 1)', 'E474:') - call assert_fails('let x = charidx("abc", [])', 'E474:') - call assert_fails('let x = charidx("abc", 1, [])', 'E474:') - call assert_fails('let x = charidx("abc", 1, -1)', 'E1023:') - call assert_fails('let x = charidx("abc", 1, 2)', 'E1023:') + call assert_fails('let x = charidx([], 1)', 'E1174:') + call assert_fails('let x = charidx("abc", [])', 'E1210:') + call assert_fails('let x = charidx("abc", 1, [])', 'E1212:') + call assert_fails('let x = charidx("abc", 1, -1)', 'E1212:') + call assert_fails('let x = charidx("abc", 1, 2)', 'E1212:') endfunc func Test_count() @@ -1738,7 +1738,7 @@ func Test_trim() call assert_fails('eval trim(" vim ", " ", [])', 'E745:') call assert_fails('eval trim(" vim ", " ", -1)', 'E475:') call assert_fails('eval trim(" vim ", " ", 3)', 'E475:') - call assert_fails('eval trim(" vim ", 0)', 'E475:') + call assert_fails('eval trim(" vim ", 0)', 'E1174:') let chars = join(map(range(1, 0x20) + [0xa0], {n -> n->nr2char()}), '') call assert_equal("x", trim(chars . "x" . chars)) @@ -2913,7 +2913,7 @@ endfunc " Test for gettext() func Test_gettext() - call assert_fails('call gettext(1)', 'E475:') + call assert_fails('call gettext(1)', 'E1174:') endfunc func Test_builtin_check() diff --git a/src/testdir/test_gf.vim b/src/testdir/test_gf.vim index 04228b2c13..53571d8add 100644 --- a/src/testdir/test_gf.vim +++ b/src/testdir/test_gf.vim @@ -49,38 +49,38 @@ endfunc func Test_gF() new call setline(1, ['111', '222', '333', '444']) - w! Xfile + w! Xgffile close new set isfname-=: - call setline(1, ['one', 'Xfile:3', 'three']) + call setline(1, ['one', 'Xgffile:3', 'three']) 2 call assert_fails('normal gF', 'E37:') call assert_equal(2, getcurpos()[1]) - w! Xfile2 + w! Xgffile2 normal gF - call assert_equal('Xfile', bufname('%')) + call assert_equal('Xgffile', bufname('%')) call assert_equal(3, getcurpos()[1]) enew! - call setline(1, ['one', 'the Xfile line 2, and more', 'three']) - w! Xfile2 + call setline(1, ['one', 'the Xgffile line 2, and more', 'three']) + w! Xgffile2 normal 2GfX normal gF - call assert_equal('Xfile', bufname('%')) + call assert_equal('Xgffile', bufname('%')) call assert_equal(2, getcurpos()[1]) " jumping to the file/line with CTRL-W_F %bw! edit Xfile1 - call setline(1, ['one', 'Xfile:4', 'three']) + call setline(1, ['one', 'Xgffile:4', 'three']) exe "normal 2G\F" - call assert_equal('Xfile', bufname('%')) + call assert_equal('Xgffile', bufname('%')) call assert_equal(4, getcurpos()[1]) set isfname& - call delete('Xfile') - call delete('Xfile2') + call delete('Xgffile') + call delete('Xgffile2') %bw! endfunc diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim index fe6a76b707..9ea2de04fd 100644 --- a/src/testdir/test_gui.vim +++ b/src/testdir/test_gui.vim @@ -1609,7 +1609,7 @@ endfunc func Test_gui_dialog_file() let lines =<< trim END - file Xfile + file Xdialfile normal axxx confirm qa END @@ -1622,14 +1622,14 @@ func Test_gui_dialog_file() call WaitForAssert({-> assert_true(filereadable('Xdialog'))}) if has('gui_macvim') - call assert_match('Do you want to save the changes you made in the document "Xfile"?: ' .. + call assert_match('Do you want to save the changes you made in the document "Xdialfile"?: ' .. \ 'Your changes will be lost if you don''t save them.', readfile('Xdialog')->join('')) else - call assert_match('Question: Save changes to "Xfile"?', readfile('Xdialog')->join('')) + call assert_match('Question: Save changes to "Xdialfile"?', readfile('Xdialog')->join('')) endif call delete('Xdialog') - call delete('Xfile') + call delete('Xdialfile') call delete('Xlines') endfunc diff --git a/src/testdir/test_indent.vim b/src/testdir/test_indent.vim index 3b5b643177..97c44b8bb5 100644 --- a/src/testdir/test_indent.vim +++ b/src/testdir/test_indent.vim @@ -161,9 +161,9 @@ func Test_modeline_indent_expr() func GetIndent() return line('.') * 2 endfunc - call writefile(['# vim: indentexpr=GetIndent()'], 'Xfile.txt') + call writefile(['# vim: indentexpr=GetIndent()'], 'Xmlfile.txt') set modelineexpr - new Xfile.txt + new Xmlfile.txt call assert_equal('GetIndent()', &indentexpr) exe "normal Oa\nb\n" call assert_equal([' a', ' b'], getline(1, 2)) @@ -172,7 +172,7 @@ func Test_modeline_indent_expr() delfunc GetIndent let &modeline = modeline close! - call delete('Xfile.txt') + call delete('Xmlfile.txt') endfunc func Test_indent_func_with_gq() diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index cee6a329f7..a79a7867fe 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -1226,14 +1226,14 @@ func Test_complete_unreadable_thesaurus_file() CheckUnix CheckNotRoot - call writefile(['about', 'above'], 'Xfile') - call setfperm('Xfile', '---r--r--') + call writefile(['about', 'above'], 'Xunrfile') + call setfperm('Xunrfile', '---r--r--') new set complete=sXfile exe "normal! ia\" call assert_equal('a', getline(1)) bw! - call delete('Xfile') + call delete('Xunrfile') set complete& endfunc diff --git a/src/testdir/test_let.vim b/src/testdir/test_let.vim index fb315e89ed..9822e6f1b7 100644 --- a/src/testdir/test_let.vim +++ b/src/testdir/test_let.vim @@ -8,6 +8,10 @@ func Test_let() let Test104#numvar = function('tr') call assert_equal("function('tr')", string(Test104#numvar)) + let foo#tr = function('tr') + call assert_equal("function('tr')", string(foo#tr)) + unlet foo#tr + let a = 1 let b = 2 diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim index 154aa9875d..bf3117bbbd 100644 --- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -568,7 +568,7 @@ func Test_dict_deepcopy() END call v9.CheckLegacyAndVim9Success(lines) - call assert_fails("call deepcopy([1, 2], 2)", 'E1023:') + call assert_fails("call deepcopy([1, 2], 2)", 'E1212:') endfunc " Locked variables @@ -1044,16 +1044,16 @@ func Test_reduce() call assert_fails("call reduce({}, { acc, val -> acc + val }, 1)", 'E1098:') call assert_fails("call reduce(0, { acc, val -> acc + val }, 1)", 'E1098:') call assert_fails("call reduce([1, 2], 'Xdoes_not_exist')", 'E117:') - call assert_fails("echo reduce(0z01, { acc, val -> 2 * acc + val }, '')", 'E39:') + call assert_fails("echo reduce(0z01, { acc, val -> 2 * acc + val }, '')", 'E1210:') call assert_fails("vim9 reduce(0, (acc, val) => (acc .. val), '')", 'E1252:') call assert_fails("vim9 reduce({}, (acc, val) => (acc .. val), '')", 'E1252:') call assert_fails("vim9 reduce(0.1, (acc, val) => (acc .. val), '')", 'E1252:') call assert_fails("vim9 reduce(function('tr'), (acc, val) => (acc .. val), '')", 'E1252:') - call assert_fails("call reduce('', { acc, val -> acc + val }, 1)", 'E1253:') - call assert_fails("call reduce('', { acc, val -> acc + val }, {})", 'E1253:') - call assert_fails("call reduce('', { acc, val -> acc + val }, 0.1)", 'E1253:') - call assert_fails("call reduce('', { acc, val -> acc + val }, function('tr'))", 'E1253:') + call assert_fails("call reduce('', { acc, val -> acc + val }, 1)", 'E1174:') + call assert_fails("call reduce('', { acc, val -> acc + val }, {})", 'E1174:') + call assert_fails("call reduce('', { acc, val -> acc + val }, 0.1)", 'E1174:') + call assert_fails("call reduce('', { acc, val -> acc + val }, function('tr'))", 'E1174:') call assert_fails("call reduce('abc', { a, v -> a10}, '')", 'E121:') call assert_fails("call reduce(0z0102, { a, v -> a10}, 1)", 'E121:') call assert_fails("call reduce([1, 2], { a, v -> a10}, '')", 'E121:') diff --git a/src/testdir/test_listener.vim b/src/testdir/test_listener.vim index 82b5ff03c9..413275d464 100644 --- a/src/testdir/test_listener.vim +++ b/src/testdir/test_listener.vim @@ -387,6 +387,37 @@ func Test_remove_listener_in_callback() unlet g:listener_called endfunc +" When multiple listeners are registered, remove one listener and verify the +" other listener is still called +func Test_remove_one_listener_in_callback() + new + let g:listener1_called = 0 + let g:listener2_called = 0 + let s:ID1 = listener_add('Listener1') + let s:ID2 = listener_add('Listener2') + func Listener1(...) + call listener_remove(s:ID1) + let g:listener1_called += 1 + endfunc + func Listener2(...) + let g:listener2_called += 1 + endfunc + call setline(1, ['foo']) + call feedkeys("~", 'xt') + call listener_flush() + call feedkeys("~", 'xt') + call listener_flush() + call assert_equal(1, g:listener1_called) + call assert_equal(2, g:listener2_called) + + call listener_remove(s:ID2) + bwipe! + delfunc Listener1 + delfunc Listener2 + unlet g:listener1_called + unlet g:listener2_called +endfunc + func Test_no_change_for_empty_undo() new let text = ['some word here', 'second line'] diff --git a/src/testdir/test_messages.vim b/src/testdir/test_messages.vim index 10af69c67d..07a4b229a7 100644 --- a/src/testdir/test_messages.vim +++ b/src/testdir/test_messages.vim @@ -420,5 +420,25 @@ func Test_echowindow() call delete('XtestEchowindow') endfunc +" messages window should not be used while evaluating the :echowin argument +func Test_echowin_eval() + CheckScreendump + + let lines =<< trim END + func ShowMessage() + echo 123 + return 'test' + endfunc + echowindow ShowMessage() + END + call writefile(lines, 'XtestEchowindow') + let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8}) + call VerifyScreenDump(buf, 'Test_echowin_eval', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('XtestEchowindow') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_mksession.vim b/src/testdir/test_mksession.vim index c916b1a517..92cf8bfa5d 100644 --- a/src/testdir/test_mksession.vim +++ b/src/testdir/test_mksession.vim @@ -1235,8 +1235,8 @@ endfunc " Test for creating views with manual folds func Test_mkview_manual_fold() - call writefile(range(1,10), 'Xfile') - new Xfile + call writefile(range(1,10), 'Xmkvfile') + new Xmkvfile " create recursive folds 5,6fold 4,7fold @@ -1259,7 +1259,7 @@ func Test_mkview_manual_fold() source Xview call assert_equal([-1, -1, -1, -1, -1, -1], [foldclosed(3), foldclosed(4), \ foldclosed(5), foldclosed(6), foldclosed(7), foldclosed(8)]) - call delete('Xfile') + call delete('Xmkvfile') call delete('Xview') bw! endfunc diff --git a/src/testdir/test_modeline.vim b/src/testdir/test_modeline.vim index f28ad3e84f..fc0779b5f5 100644 --- a/src/testdir/test_modeline.vim +++ b/src/testdir/test_modeline.vim @@ -350,13 +350,13 @@ endfunc " Some options cannot be set from the modeline when 'diff' option is set func Test_modeline_diff_buffer() - call writefile(['vim: diff foldmethod=marker wrap'], 'Xfile') + call writefile(['vim: diff foldmethod=marker wrap'], 'Xmdifile') set foldmethod& nowrap - new Xfile + new Xmdifile call assert_equal('manual', &foldmethod) call assert_false(&wrap) set wrap& - call delete('Xfile') + call delete('Xmdifile') bw endfunc diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index 86f0ef656b..352c609481 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -1709,14 +1709,14 @@ endfunc func Test_normal20_exmode() " Reading from redirected file doesn't work on MS-Windows CheckNotMSWindows - call writefile(['1a', 'foo', 'bar', '.', 'w! Xfile2', 'q!'], 'Xscript') - call writefile(['1', '2'], 'Xfile') - call system(GetVimCommand() .. ' -e -s < Xscript Xfile') - let a=readfile('Xfile2') + call writefile(['1a', 'foo', 'bar', '.', 'w! Xn20file2', 'q!'], 'Xn20script') + call writefile(['1', '2'], 'Xn20file') + call system(GetVimCommand() .. ' -e -s < Xn20script Xn20file') + let a=readfile('Xn20file2') call assert_equal(['1', 'foo', 'bar', '2'], a) " clean up - for file in ['Xfile', 'Xfile2', 'Xscript'] + for file in ['Xn20file', 'Xn20file2', 'Xn20script'] call delete(file) endfor bw! @@ -1758,22 +1758,22 @@ func Test_normal22_zet() " Test for ZZ " let shell = &shell " let &shell = 'sh' - call writefile(['1', '2'], 'Xfile') + call writefile(['1', '2'], 'Xn22file') let args = ' -N -i NONE --noplugins -X --not-a-term' - call system(GetVimCommand() .. args .. ' -c "%d" -c ":norm! ZZ" Xfile') - let a = readfile('Xfile') + call system(GetVimCommand() .. args .. ' -c "%d" -c ":norm! ZZ" Xn22file') + let a = readfile('Xn22file') call assert_equal([], a) " Test for ZQ - call writefile(['1', '2'], 'Xfile') - call system(GetVimCommand() . args . ' -c "%d" -c ":norm! ZQ" Xfile') - let a = readfile('Xfile') + call writefile(['1', '2'], 'Xn22file') + call system(GetVimCommand() . args . ' -c "%d" -c ":norm! ZQ" Xn22file') + let a = readfile('Xn22file') call assert_equal(['1', '2'], a) " Unsupported Z command call assert_beeps('normal! ZW') " clean up - for file in ['Xfile'] + for file in ['Xn22file'] call delete(file) endfor " let &shell = shell diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index 3cdc345608..bfb4f2c071 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -888,7 +888,7 @@ func Test_write() new call setline(1, ['L1']) set nowrite - call assert_fails('write Xfile', 'E142:') + call assert_fails('write Xwrfile', 'E142:') set write close! endfunc diff --git a/src/testdir/test_plus_arg_edit.vim b/src/testdir/test_plus_arg_edit.vim index e9019c1181..7213b20584 100644 --- a/src/testdir/test_plus_arg_edit.vim +++ b/src/testdir/test_plus_arg_edit.vim @@ -12,26 +12,26 @@ endfunction func Test_edit_bad() " Test loading a utf8 file with bad utf8 sequences. - call writefile(["[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]"], "Xfile") + call writefile(["[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]"], "Xbadfile") new " Without ++bad=..., the default behavior is like ++bad=? - e! ++enc=utf8 Xfile + e! ++enc=utf8 Xbadfile call assert_equal('[?][?][???][??]', getline(1)) - e! ++encoding=utf8 ++bad=_ Xfile + e! ++encoding=utf8 ++bad=_ Xbadfile call assert_equal('[_][_][___][__]', getline(1)) - e! ++enc=utf8 ++bad=drop Xfile + e! ++enc=utf8 ++bad=drop Xbadfile call assert_equal('[][][][]', getline(1)) - e! ++enc=utf8 ++bad=keep Xfile + e! ++enc=utf8 ++bad=keep Xbadfile call assert_equal("[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]", getline(1)) - call assert_fails('e! ++enc=utf8 ++bad=foo Xfile', 'E474:') + call assert_fails('e! ++enc=utf8 ++bad=foo Xbadfile', 'E474:') bw! - call delete('Xfile') + call delete('Xbadfile') endfunc " Test for ++bin and ++nobin arguments diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index a92bd8b032..7cdd12865f 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -4104,7 +4104,7 @@ endfunc func Test_popup_setoptions_other_tab() - new Xfile + new Xpotfile let winid = win_getid() call setline(1, 'some text') call prop_type_add('textprop', {}) @@ -4116,7 +4116,7 @@ func Test_popup_setoptions_other_tab() tabclose call popup_close(id) - bwipe! Xfile + bwipe! Xpotfile call prop_type_delete('textprop') endfunc diff --git a/src/testdir/test_python2.vim b/src/testdir/test_python2.vim index 3fc3c204c5..af1e340fae 100644 --- a/src/testdir/test_python2.vim +++ b/src/testdir/test_python2.vim @@ -1565,11 +1565,11 @@ func Test_python_buffer() %bw! " Range object for a deleted buffer - new Xfile + new Xpbuffile call setline(1, ['one', 'two', 'three']) py b = vim.current.buffer py r = vim.current.buffer.range(0, 2) - call assert_equal('', pyeval('repr(r)')) + call assert_equal('', pyeval('repr(r)')) %bw! call AssertException(['py r[:] = []'], \ 'Vim(python):vim.error: attempt to refer to deleted buffer') @@ -1598,7 +1598,7 @@ endfunc " Test vim.buffers object func Test_python_buffers() %bw! - edit Xfile + edit Xpbuffile py cb = vim.current.buffer set hidden edit a @@ -1626,8 +1626,8 @@ func Test_python_buffers() cb.append('i3:' + str(next(i3))) del i3 EOF - call assert_equal(['i:', - \ 'i2:', 'i:', 'i3:'], + call assert_equal(['i:', + \ 'i2:', 'i:', 'i3:'], \ getline(2, '$')) %d @@ -1645,7 +1645,7 @@ func Test_python_buffers() cb.append(str(len(vim.buffers))) EOF - call assert_equal([bufnr('Xfile') .. ':=', + call assert_equal([bufnr('Xpbuffile') .. ':=', \ bufnr('a') .. ':=', \ bufnr('b') .. ':=', \ bufnr('c') .. ':=', '4'], getline(2, '$')) @@ -1675,15 +1675,15 @@ func Test_python_buffers() del i4 del bnums EOF - call assert_equal(['i4:', - \ 'i4:', 'StopIteration'], getline(2, '$')) + call assert_equal(['i4:', + \ 'i4:', 'StopIteration'], getline(2, '$')) %bw! endfunc " Test vim.{tabpage,window}list and vim.{tabpage,window} objects func Test_python_tabpage_window() %bw - edit Xfile + edit Xpbuffile py cb = vim.current.buffer tabnew 0 tabnew 1 @@ -1748,7 +1748,7 @@ func Test_python_tabpage_window() Current tab pages: (1): 1 windows, current is Windows: - (1): displays buffer ; cursor is at (2, 0) + (1): displays buffer ; cursor is at (2, 0) (2): 1 windows, current is Windows: (1): displays buffer ; cursor is at (1, 0) @@ -1764,14 +1764,14 @@ func Test_python_tabpage_window() (4): displays buffer ; cursor is at (1, 0) Number of windows in current tab page: 4 END - call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$')) + call assert_equal(expected, getbufline(bufnr('Xpbuffile'), 2, '$')) %bw! endfunc " Test vim.current func Test_python_vim_current() %bw - edit Xfile + edit Xpbuffile py cb = vim.current.buffer tabnew 0 tabnew 1 @@ -1797,8 +1797,8 @@ func Test_python_vim_current() Current window: : is Current buffer: : is is END - call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$')) - call deletebufline(bufnr('Xfile'), 1, '$') + call assert_equal(expected, getbufline(bufnr('Xpbuffile'), 2, '$')) + call deletebufline(bufnr('Xpbuffile'), 1, '$') " Assigning: fails py << trim EOF @@ -1821,10 +1821,10 @@ func Test_python_vim_current() Type error at assigning None to vim.current.tabpage Type error at assigning None to vim.current.buffer END - call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$')) - call deletebufline(bufnr('Xfile'), 1, '$') + call assert_equal(expected, getbufline(bufnr('Xpbuffile'), 2, '$')) + call deletebufline(bufnr('Xpbuffile'), 1, '$') - call setbufline(bufnr('Xfile'), 1, 'python interface') + call setbufline(bufnr('Xpbuffile'), 1, 'python interface') py << trim EOF # Assigning: success vim.current.tabpage = vim.tabpages[-2] @@ -1840,13 +1840,13 @@ func Test_python_vim_current() let expected =<< trim END Current tab page: Current window: - Current buffer: + Current buffer: Current line: 'python interface' END - call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$')) + call assert_equal(expected, getbufline(bufnr('Xpbuffile'), 2, '$')) py vim.current.line = 'one line' call assert_equal('one line', getline('.')) - call deletebufline(bufnr('Xfile'), 1, '$') + call deletebufline(bufnr('Xpbuffile'), 1, '$') py << trim EOF ws = list(vim.windows) @@ -1866,7 +1866,7 @@ func Test_python_vim_current() w.valid: [True, False] t.valid: [True, False, True, False] END - call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$')) + call assert_equal(expected, getbufline(bufnr('Xpbuffile'), 2, '$')) %bw! endfunc @@ -2409,7 +2409,7 @@ endfunc " Test chdir func Test_python_chdir() - new Xfile + new Xpycfile py cb = vim.current.buffer py << trim EOF import os @@ -2420,7 +2420,7 @@ func Test_python_chdir() path = fnamemodify('.', ':p:h:t') if path != 'src' and path != 'src2': # Running tests from a shadow directory, so move up another level - # This will result in @% looking like shadow/testdir/Xfile, hence the + # This will result in @% looking like shadow/testdir/Xpycfile, hence the # extra fnamemodify os.chdir('..') cb.append(fnamemodify('.', ':p:h:t')) @@ -2436,8 +2436,8 @@ func Test_python_chdir() cb.append(vim.eval('@%')) del fnamemodify EOF - call assert_equal(['testdir', 'Xfile', 'src', 'testdir/Xfile', 'testdir', - \ 'Xfile'], getline(2, '$')) + call assert_equal(['testdir', 'Xpycfile', 'src', 'testdir/Xpycfile', 'testdir', + \ 'Xpycfile'], getline(2, '$')) close! call AssertException(["py vim.chdir(None)"], "Vim(python):TypeError:") endfunc diff --git a/src/testdir/test_python3.vim b/src/testdir/test_python3.vim index 778d83b8e0..437da513b0 100644 --- a/src/testdir/test_python3.vim +++ b/src/testdir/test_python3.vim @@ -1762,11 +1762,11 @@ func Test_python3_buffer() %bw! " Range object for a deleted buffer - new Xfile + new Xp3buffile call setline(1, ['one', 'two', 'three']) py3 b = vim.current.buffer py3 r = vim.current.buffer.range(0, 2) - call assert_equal('', py3eval('repr(r)')) + call assert_equal('', py3eval('repr(r)')) %bw! call AssertException(['py3 r[:] = []'], \ 'Vim(py3):vim.error: attempt to refer to deleted buffer') @@ -1795,7 +1795,7 @@ endfunc " Test vim.buffers object func Test_python3_buffers() %bw! - edit Xfile + edit Xp3buffile py3 cb = vim.current.buffer set hidden edit a @@ -1819,8 +1819,8 @@ func Test_python3_buffers() cb.append('i3:' + str(next(i3))) del i3 EOF - call assert_equal(['i:', - \ 'i2:', 'i:', 'i3:'], + call assert_equal(['i:', + \ 'i2:', 'i:', 'i3:'], \ getline(2, '$')) %d @@ -1838,7 +1838,7 @@ func Test_python3_buffers() cb.append(str(len(vim.buffers))) EOF - call assert_equal([bufnr('Xfile') .. ':=', + call assert_equal([bufnr('Xp3buffile') .. ':=', \ bufnr('a') .. ':=', \ bufnr('b') .. ':=', \ bufnr('c') .. ':=', '4'], getline(2, '$')) @@ -1868,15 +1868,15 @@ func Test_python3_buffers() del i4 del bnums EOF - call assert_equal(['i4:', - \ 'i4:', 'StopIteration'], getline(2, '$')) + call assert_equal(['i4:', + \ 'i4:', 'StopIteration'], getline(2, '$')) %bw! endfunc " Test vim.{tabpage,window}list and vim.{tabpage,window} objects func Test_python3_tabpage_window() %bw - edit Xfile + edit Xp3buffile py3 cb = vim.current.buffer tabnew 0 tabnew 1 @@ -1937,7 +1937,7 @@ func Test_python3_tabpage_window() Current tab pages: (1): 1 windows, current is Windows: - (1): displays buffer ; cursor is at (2, 0) + (1): displays buffer ; cursor is at (2, 0) (2): 1 windows, current is Windows: (1): displays buffer ; cursor is at (1, 0) @@ -1953,14 +1953,14 @@ func Test_python3_tabpage_window() (4): displays buffer ; cursor is at (1, 0) Number of windows in current tab page: 4 END - call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$')) + call assert_equal(expected, getbufline(bufnr('Xp3buffile'), 2, '$')) %bw! endfunc " Test vim.current func Test_python3_vim_current() %bw - edit Xfile + edit Xpy3cfile py3 cb = vim.current.buffer tabnew 0 tabnew 1 @@ -1986,8 +1986,8 @@ func Test_python3_vim_current() Current window: : is Current buffer: : is is END - call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$')) - call deletebufline(bufnr('Xfile'), 1, '$') + call assert_equal(expected, getbufline(bufnr('Xpy3cfile'), 2, '$')) + call deletebufline(bufnr('Xpy3cfile'), 1, '$') " Assigning: fails py3 << trim EOF @@ -2010,10 +2010,10 @@ func Test_python3_vim_current() Type error at assigning None to vim.current.tabpage Type error at assigning None to vim.current.buffer END - call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$')) - call deletebufline(bufnr('Xfile'), 1, '$') + call assert_equal(expected, getbufline(bufnr('Xpy3cfile'), 2, '$')) + call deletebufline(bufnr('Xpy3cfile'), 1, '$') - call setbufline(bufnr('Xfile'), 1, 'python interface') + call setbufline(bufnr('Xpy3cfile'), 1, 'python interface') py3 << trim EOF # Assigning: success vim.current.tabpage = vim.tabpages[-2] @@ -2029,13 +2029,13 @@ func Test_python3_vim_current() let expected =<< trim END Current tab page: Current window: - Current buffer: + Current buffer: Current line: 'python interface' END - call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$')) + call assert_equal(expected, getbufline(bufnr('Xpy3cfile'), 2, '$')) py3 vim.current.line = 'one line' call assert_equal('one line', getline('.')) - call deletebufline(bufnr('Xfile'), 1, '$') + call deletebufline(bufnr('Xpy3cfile'), 1, '$') py3 << trim EOF ws = list(vim.windows) @@ -2055,7 +2055,7 @@ func Test_python3_vim_current() w.valid: [True, False] t.valid: [True, False, True, False] END - call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$')) + call assert_equal(expected, getbufline(bufnr('Xpy3cfile'), 2, '$')) %bw! endfunc @@ -2598,7 +2598,7 @@ endfunc " Test chdir func Test_python3_chdir() - new Xfile + new Xp3cdfile py3 cb = vim.current.buffer py3 << trim EOF import os @@ -2609,7 +2609,7 @@ func Test_python3_chdir() path = fnamemodify('.', ':p:h:t') if path != b'src' and path != b'src2': # Running tests from a shadow directory, so move up another level - # This will result in @% looking like shadow/testdir/Xfile, hence the + # This will result in @% looking like shadow/testdir/Xp3cdfile, hence the # slicing to remove the leading path and path separator os.chdir('..') cb.append(str(fnamemodify('.', ':p:h:t'))) @@ -2625,8 +2625,8 @@ func Test_python3_chdir() cb.append(vim.eval('@%')) del fnamemodify EOF - call assert_equal(["b'testdir'", 'Xfile', "b'src'", 'testdir/Xfile', - \"b'testdir'", 'Xfile'], getline(2, '$')) + call assert_equal(["b'testdir'", 'Xp3cdfile', "b'src'", 'testdir/Xp3cdfile', + \"b'testdir'", 'Xp3cdfile'], getline(2, '$')) close! call AssertException(["py3 vim.chdir(None)"], "Vim(py3):TypeError:") endfunc diff --git a/src/testdir/test_signs.vim b/src/testdir/test_signs.vim index e2387b28c7..790d9b4379 100644 --- a/src/testdir/test_signs.vim +++ b/src/testdir/test_signs.vim @@ -686,7 +686,7 @@ func Test_sign_group() call assert_equal([], sign_getplaced(bnum, {'group' : '*'})[0].signs) " Error case - call assert_fails("call sign_unplace({})", 'E474:') + call assert_fails("call sign_unplace({})", 'E1174:') " Place a sign in the global group and try to delete it using a group call assert_equal(5, sign_place(5, '', 'sign1', bnum, {'lnum' : 10})) diff --git a/src/testdir/test_source.vim b/src/testdir/test_source.vim index 4736e93546..44cd2fdc72 100644 --- a/src/testdir/test_source.vim +++ b/src/testdir/test_source.vim @@ -63,10 +63,10 @@ endfunc " When sourcing a vim script, shebang should be ignored. func Test_source_ignore_shebang() - call writefile(['#!./xyzabc', 'let g:val=369'], 'Xfile.vim') - source Xfile.vim + call writefile(['#!./xyzabc', 'let g:val=369'], 'Xsisfile.vim') + source Xsisfile.vim call assert_equal(g:val, 369) - call delete('Xfile.vim') + call delete('Xsisfile.vim') endfunc " Test for expanding in an autocmd and for and @@ -480,12 +480,12 @@ func Test_source_buffer_vim9() augroup Test au! - au BufNewFile Xfile g:readFile = 1 + au BufNewFile Xsubfile g:readFile = 1 | g:readExtra = 2 augroup END g:readFile = 0 g:readExtra = 0 - new Xfile + new Xsubfile bwipe! augroup Test au! diff --git a/src/testdir/test_stat.vim b/src/testdir/test_stat.vim index de4a204f5d..e801bfc5ce 100644 --- a/src/testdir/test_stat.vim +++ b/src/testdir/test_stat.vim @@ -171,7 +171,7 @@ func Test_getftype() return endif - silent !ln -s Xfile Xlink + silent !ln -s Xlinkfile Xlink call assert_equal('link', getftype('Xlink')) call delete('Xlink') diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim index 7e7ccff0f5..df01e06f3a 100644 --- a/src/testdir/test_substitute.vim +++ b/src/testdir/test_substitute.vim @@ -141,7 +141,7 @@ endfunc func Test_substitute_repeat() " This caused an invalid memory access. - split Xfile + split Xsubfile s/^/x call feedkeys("Qsc\y", 'tx') bwipe! @@ -1068,7 +1068,7 @@ func Test_sub_edit_scriptfile() new norm o0000000000000000000000000000000000000000000000000000 func EditScript() - silent! scr! Xfile + silent! scr! Xsedfile endfunc s/\%')/\=EditScript() diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim index 7e105b1254..fe97578b10 100644 --- a/src/testdir/test_tabpage.vim +++ b/src/testdir/test_tabpage.vim @@ -768,14 +768,14 @@ endfunc func Test_tabpage_close_on_switch() tabnew tabnew - edit Xfile + edit Xtabfile augroup T2 au! - au BufLeave Xfile 1tabclose + au BufLeave Xtabfile 1tabclose augroup END tabfirst call assert_equal(2, tabpagenr()) - call assert_equal('Xfile', @%) + call assert_equal('Xtabfile', @%) augroup T2 au! augroup END diff --git a/src/testdir/test_tagjump.vim b/src/testdir/test_tagjump.vim index cca907f3b2..59537ee299 100644 --- a/src/testdir/test_tagjump.vim +++ b/src/testdir/test_tagjump.vim @@ -15,20 +15,20 @@ endfunc func Test_ptjump() CheckFeature quickfix - set tags=Xtags + set tags=Xpttags call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", - \ "one\tXfile\t1", - \ "three\tXfile\t3", - \ "two\tXfile\t2"], - \ 'Xtags') - call writefile(['one', 'two', 'three'], 'Xfile') + \ "one\tXptfile\t1", + \ "three\tXptfile\t3", + \ "two\tXptfile\t2"], + \ 'Xpttags') + call writefile(['one', 'two', 'three'], 'Xptfile') %bw! ptjump two call assert_equal(2, winnr()) wincmd p call assert_equal(1, &previewwindow) - call assert_equal('Xfile', expand("%:p:t")) + call assert_equal('Xptfile', expand("%:p:t")) call assert_equal(2, line('.')) call assert_equal(2, winnr('$')) call assert_equal(1, winnr()) @@ -38,7 +38,7 @@ func Test_ptjump() call assert_equal(2, winnr()) wincmd p call assert_equal(1, &previewwindow) - call assert_equal('Xfile', expand("%:p:t")) + call assert_equal('Xptfile', expand("%:p:t")) call assert_equal(3, line('.')) call assert_equal(2, winnr('$')) call assert_equal(1, winnr()) @@ -48,8 +48,8 @@ func Test_ptjump() call assert_equal(5, winheight(0)) close - call delete('Xtags') - call delete('Xfile') + call delete('Xpttags') + call delete('Xptfile') set tags& endfunc @@ -73,12 +73,12 @@ func Test_cancel_ptjump() endfunc func Test_static_tagjump() - set tags=Xtags + set tags=Xtjtags call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", - \ "one\tXfile1\t/^one/;\"\tf\tfile:\tsignature:(void)", - \ "word\tXfile2\tcmd2"], - \ 'Xtags') - new Xfile1 + \ "one\tXtjfile1\t/^one/;\"\tf\tfile:\tsignature:(void)", + \ "word\tXtjfile2\tcmd2"], + \ 'Xtjtags') + new Xtjfile1 call setline(1, ['empty', 'one()', 'empty']) write tag one @@ -86,19 +86,19 @@ func Test_static_tagjump() bwipe! set tags& - call delete('Xtags') - call delete('Xfile1') + call delete('Xtjtags') + call delete('Xtjfile1') endfunc func Test_duplicate_tagjump() - set tags=Xtags + set tags=Xdttags call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", - \ "thesame\tXfile1\t1;\"\td\tfile:", - \ "thesame\tXfile1\t2;\"\td\tfile:", - \ "thesame\tXfile1\t3;\"\td\tfile:", + \ "thesame\tXdtfile1\t1;\"\td\tfile:", + \ "thesame\tXdtfile1\t2;\"\td\tfile:", + \ "thesame\tXdtfile1\t3;\"\td\tfile:", \ ], - \ 'Xtags') - new Xfile1 + \ 'Xdttags') + new Xdtfile1 call setline(1, ['thesame one', 'thesame two', 'thesame three']) write tag thesame @@ -110,19 +110,19 @@ func Test_duplicate_tagjump() bwipe! set tags& - call delete('Xtags') - call delete('Xfile1') + call delete('Xdttags') + call delete('Xdtfile1') endfunc func Test_tagjump_switchbuf() CheckFeature quickfix - set tags=Xtags + set tags=Xswtags call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", - \ "second\tXfile1\t2", - \ "third\tXfile1\t3",], - \ 'Xtags') - call writefile(['first', 'second', 'third'], 'Xfile1') + \ "second\tXsbfile1\t2", + \ "third\tXsbfile1\t3",], + \ 'Xswtags') + call writefile(['first', 'second', 'third'], 'Xsbfile1') enew | only set switchbuf= @@ -153,8 +153,8 @@ func Test_tagjump_switchbuf() tabclose! enew | only - call delete('Xfile1') - call delete('Xtags') + call delete('Xsbfile1') + call delete('Xswtags') set tags& set switchbuf&vim endfunc @@ -205,14 +205,14 @@ func Test_tag_symbolic() call writefile([ \ "SECTION_OFF " . getcwd() . "/Xtest.dir/Xtest.c /^#define SECTION_OFF 3$/", \ '', - \ ], 'Xtags') + \ ], 'Xsymtags') call writefile(['#define SECTION_OFF 3', \ '#define NUM_SECTIONS 3'], 'Xtest.c') " Try jumping to a tag, but with a path that contains a symbolic link. When " wrong, this will give the ATTENTION message. The next space will then be " eaten by hit-return, instead of moving the cursor to 'd'. - set tags=Xtags + set tags=Xsymtags enew! call append(0, 'SECTION_OFF') call cursor(1,1) @@ -223,7 +223,7 @@ func Test_tag_symbolic() set hidden& set tags& enew! - call delete('Xtags') + call delete('Xsymtags') call delete('Xtest.c') call delete("Xtest.dir", "rf") %bwipe! @@ -263,12 +263,12 @@ func Test_tag_file_encoding() new let content = ['!_TAG_FILE_ENCODING cp932 //', \ "\x82`\x82a\x82b Xtags2.txt /\x82`\x82a\x82b"] - call writefile(content, 'Xtags') - set tags=Xtags + call writefile(content, 'Xenctags') + set tags=Xenctags tag /.BC call assert_equal('Xtags2.txt', expand('%:t')) call assert_equal('ABC', getline('.')) - call delete('Xtags') + call delete('Xenctags') close " case3: @@ -280,12 +280,12 @@ func Test_tag_file_encoding() call add(contents, 'abc' .. i \ .. " Xtags3.txt /\x82`\x82a\x82b") endfor - call writefile(contents, 'Xtags') - set tags=Xtags + call writefile(contents, 'Xenctags') + set tags=Xenctags tag abc50 call assert_equal('Xtags3.txt', expand('%:t')) call assert_equal('ABC', getline('.')) - call delete('Xtags') + call delete('Xenctags') close set tags& @@ -314,8 +314,8 @@ func Test_tagjump_etags() \ "Xmain.c,64", \ "void foo() {}\x7ffoo\x011,0", \ "int main(int argc, char **argv)\x7fmain\x012,14", - \ ], 'Xtags') - set tags=Xtags + \ ], 'Xtetags') + set tags=Xtetags ta foo call assert_equal('void foo() {}', getline('.')) @@ -328,7 +328,7 @@ func Test_tagjump_etags() \ "Xnonexisting,include", \ "\x0c", \ "Xtags2,include" - \ ], 'Xtags') + \ ], 'Xtetags') call writefile([ \ "\x0c", \ "Xmain.c,64", @@ -343,7 +343,7 @@ func Test_tagjump_etags() \ "\x0c", \ "Xmain.c,8", \ "int main" - \ ], 'Xtags', 'b') + \ ], 'Xtetags', 'b') call assert_fails('tag foo', 'E426:') " invalid line number @@ -351,7 +351,7 @@ func Test_tagjump_etags() \ "\x0c", \ "Xmain.c,64", \ "void foo() {}\x7ffoo\x0abc,0", - \ ], 'Xtags') + \ ], 'Xtetags') call assert_fails('tag foo', 'E426:') " invalid tag name @@ -359,7 +359,7 @@ func Test_tagjump_etags() \ "\x0c", \ "Xmain.c,64", \ ";;;;\x7f1,0", - \ ], 'Xtags') + \ ], 'Xtetags') call assert_fails('tag foo', 'E431:') " end of file after a CTRL-L line @@ -368,14 +368,14 @@ func Test_tagjump_etags() \ "Xmain.c,64", \ "void foo() {}\x7ffoo\x011,0", \ "\x0c", - \ ], 'Xtags') + \ ], 'Xtetags') call assert_fails('tag main', 'E426:') " error in an included tags file call writefile([ \ "\x0c", \ "Xtags2,include" - \ ], 'Xtags') + \ ], 'Xtetags') call writefile([ \ "\x0c", \ "Xmain.c,64", @@ -383,7 +383,7 @@ func Test_tagjump_etags() \ ], 'Xtags2') call assert_fails('tag foo', 'E431:') - call delete('Xtags') + call delete('Xtetags') call delete('Xtags2') call delete('Xmain.c') set tags& @@ -392,9 +392,9 @@ endfunc " Test for getting and modifying the tag stack func Test_getsettagstack() - call writefile(['line1', 'line2', 'line3'], 'Xfile1') - call writefile(['line1', 'line2', 'line3'], 'Xfile2') - call writefile(['line1', 'line2', 'line3'], 'Xfile3') + call writefile(['line1', 'line2', 'line3'], 'Xstsfile1') + call writefile(['line1', 'line2', 'line3'], 'Xstsfile2') + call writefile(['line1', 'line2', 'line3'], 'Xstsfile3') enew | only call settagstack(1, {'items' : []}) @@ -405,16 +405,16 @@ func Test_getsettagstack() call assert_equal(-1, settagstack(100, {'items' : []})) call assert_fails('call settagstack(1, [1, 10])', 'E1206:') call assert_fails("call settagstack(1, {'items' : 10})", 'E714:') - call assert_fails("call settagstack(1, {'items' : []}, 10)", 'E928:') + call assert_fails("call settagstack(1, {'items' : []}, 10)", 'E1174:') call assert_fails("call settagstack(1, {'items' : []}, 'b')", 'E962:') call assert_equal(-1, settagstack(0, test_null_dict())) - set tags=Xtags + set tags=Xtsttags call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", - \ "one\tXfile1\t1", - \ "three\tXfile3\t3", - \ "two\tXfile2\t2"], - \ 'Xtags') + \ "one\tXstsfile1\t1", + \ "three\tXstsfile3\t3", + \ "two\tXstsfile2\t2"], + \ 'Xtsttags') let stk = [] call add(stk, {'bufnr' : bufnr('%'), 'tagname' : 'one', @@ -495,10 +495,10 @@ func Test_getsettagstack() " Tag with multiple matches call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", - \ "two\tXfile1\t1", - \ "two\tXfile2\t3", - \ "two\tXfile3\t2"], - \ 'Xtags') + \ "two\tXstsfile1\t1", + \ "two\tXstsfile2\t3", + \ "two\tXstsfile3\t2"], + \ 'Xtsttags') call settagstack(1, {'items' : []}) tag two tnext @@ -515,10 +515,10 @@ func Test_getsettagstack() call assert_fails('call gettagstack()', 'E342:') call settagstack(1, {'items' : []}) - call delete('Xfile1') - call delete('Xfile2') - call delete('Xfile3') - call delete('Xtags') + call delete('Xstsfile1') + call delete('Xstsfile2') + call delete('Xstsfile3') + call delete('Xtsttags') set tags& endfunc @@ -735,11 +735,11 @@ endfunc " Test for :ptag func Test_tag_preview() call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", - \ "second\tXfile1\t2", - \ "third\tXfile1\t3",], + \ "second\tXtpfile1\t2", + \ "third\tXtpfile1\t3",], \ 'Xtags') set tags=Xtags - call writefile(['first', 'second', 'third'], 'Xfile1') + call writefile(['first', 'second', 'third'], 'Xtpfile1') enew | only ptag third @@ -766,7 +766,7 @@ func Test_tag_preview() pclose call assert_equal(1, winnr('$')) - call delete('Xfile1') + call delete('Xtpfile1') call delete('Xtags') set tags& endfunc @@ -1453,24 +1453,24 @@ endfunc func Test_tag_length() set tags=Xtags call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", - \ "tame\tXfile1\t1;", - \ "tape\tXfile2\t1;"], 'Xtags') - call writefile(['tame'], 'Xfile1') - call writefile(['tape'], 'Xfile2') + \ "tame\tXtlfile1\t1;", + \ "tape\tXtlfile2\t1;"], 'Xtags') + call writefile(['tame'], 'Xtlfile1') + call writefile(['tape'], 'Xtlfile2') " Jumping to the tag 'tape', should instead jump to 'tame' new set taglength=2 tag tape - call assert_equal('Xfile1', @%) + call assert_equal('Xtlfile1', @%) " Tag search should jump to the right tag enew tag /^tape$ - call assert_equal('Xfile2', @%) + call assert_equal('Xtlfile2', @%) call delete('Xtags') - call delete('Xfile1') - call delete('Xfile2') + call delete('Xtlfile1') + call delete('Xtlfile2') set tags& taglength& endfunc diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 08f7224b1f..4e1e4a114d 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -641,10 +641,10 @@ endfunc func Test_terminal_cwd_failure() " Case 1: Provided directory is not actually a directory. Attempt to make " the file executable as well. - call writefile([], 'Xfile') - call setfperm('Xfile', 'rwx------') - call assert_fails("call term_start(&shell, {'cwd': 'Xfile'})", 'E475:') - call delete('Xfile') + call writefile([], 'Xtcfile') + call setfperm('Xtcfile', 'rwx------') + call assert_fails("call term_start(&shell, {'cwd': 'Xtcfile'})", 'E475:') + call delete('Xtcfile') " Case 2: Directory does not exist. call assert_fails("call term_start(&shell, {'cwd': 'Xdir'})", 'E475:') @@ -878,12 +878,12 @@ endfunc func Test_terminal_redir_file() let g:test_is_flaky = 1 let cmd = Get_cat_123_cmd() - let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xfile'}) + let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xtrfile'}) call TermWait(buf) " ConPTY may precede escape sequence. There are things that are not so. if !has('conpty') - call WaitForAssert({-> assert_notequal(0, len(readfile("Xfile")))}) - call assert_match('123', readfile('Xfile')[0]) + call WaitForAssert({-> assert_notequal(0, len(readfile("Xtrfile")))}) + call assert_match('123', readfile('Xtrfile')[0]) endif let g:job = term_getjob(buf) call WaitForAssert({-> assert_equal("dead", job_status(g:job))}) @@ -894,18 +894,18 @@ func Test_terminal_redir_file() " Just wait for a moment. sleep 50m endif - call delete('Xfile') + call delete('Xtrfile') bwipe if has('unix') - call writefile(['one line'], 'Xfile') - let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xfile'}) + call writefile(['one line'], 'Xtrfile') + let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xtrfile'}) call TermWait(buf) call WaitForAssert({-> assert_equal('one line', term_getline(buf, 1))}) let g:job = term_getjob(buf) call WaitForAssert({-> assert_equal('dead', job_status(g:job))}) bwipe - call delete('Xfile') + call delete('Xtrfile') endif endfunc diff --git a/src/testdir/test_terminal2.vim b/src/testdir/test_terminal2.vim index a40fc84885..6e70ad6cce 100644 --- a/src/testdir/test_terminal2.vim +++ b/src/testdir/test_terminal2.vim @@ -415,11 +415,11 @@ func Test_terminal_does_not_truncate_last_newlines() \ ] for c in contents - call writefile(c, 'Xfile') + call writefile(c, 'Xdntfile') if has('win32') - term cmd /c type Xfile + term cmd /c type Xdntfile else - term cat Xfile + term cat Xdntfile endif let bnr = bufnr('$') call assert_equal('terminal', getbufvar(bnr, '&buftype')) @@ -429,7 +429,7 @@ func Test_terminal_does_not_truncate_last_newlines() quit endfor - call delete('Xfile') + call delete('Xdntfile') endfunc func GetDummyCmd() diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index 03ae9c97e0..21d751fb14 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -1925,12 +1925,21 @@ func Test_prop_in_linebreak() let lines =<< trim END set breakindent linebreak breakat+=] call printf('%s]%s', repeat('x', 50), repeat('x', 70))->setline(1) - call prop_type_add('test', #{highlight: 'ErrorMsg'}) + call prop_type_add('test', #{highlight: 'MatchParen'}) call prop_add(1, 51, #{length: 1, type: 'test'}) + func AddMatch() + syntax on + syntax match xTest /.*/ + hi link xTest Comment + set signcolumn=yes + endfunc END call writefile(lines, 'XscriptPropLinebreak') let buf = RunVimInTerminal('-S XscriptPropLinebreak', #{rows: 10}) - call VerifyScreenDump(buf, 'Test_prop_linebreak', {}) + call VerifyScreenDump(buf, 'Test_prop_linebreak_1', {}) + + call term_sendkeys(buf, ":call AddMatch()\") + call VerifyScreenDump(buf, 'Test_prop_linebreak_2', {}) call StopVimInTerminal(buf) call delete('XscriptPropLinebreak') diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim index 85e76eb863..2625013ae4 100644 --- a/src/testdir/test_timers.vim +++ b/src/testdir/test_timers.vim @@ -116,7 +116,7 @@ func Test_timer_info() call timer_stop(id) call assert_equal([], timer_info(id)) - call assert_fails('call timer_info("abc")', 'E39:') + call assert_fails('call timer_info("abc")', 'E1210:') " check repeat count inside the callback let g:timer_repeat = [] @@ -267,7 +267,7 @@ func Test_timer_errors() call assert_fails('call timer_start(100, "MyHandler", "abc")', 'E1206:') call assert_fails('call timer_start(100, [])', 'E921:') - call assert_fails('call timer_stop("abc")', 'E39:') + call assert_fails('call timer_stop("abc")', 'E1210:') endfunc func FuncWithCaughtError(timer) diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim index f6e25e3b5a..af05812c6b 100644 --- a/src/testdir/test_user_func.vim +++ b/src/testdir/test_user_func.vim @@ -529,4 +529,36 @@ func Test_funcdef_alloc_failure() bw! endfunc +func AddDefer(arg) + call extend(g:deferred, [a:arg]) +endfunc + +func WithDeferTwo() + call extend(g:deferred, ['in Two']) + for nr in range(3) + defer AddDefer('Two' .. nr) + endfor + call extend(g:deferred, ['end Two']) +endfunc + +func WithDeferOne() + call extend(g:deferred, ['in One']) + call writefile(['text'], 'Xfuncdefer') + defer delete('Xfuncdefer') + defer AddDefer('One') + call WithDeferTwo() + call extend(g:deferred, ['end One']) +endfunc + +func Test_defer() + let g:deferred = [] + call WithDeferOne() + + call assert_equal(['in One', 'in Two', 'end Two', 'Two2', 'Two1', 'Two0', 'end One', 'One'], g:deferred) + unlet g:deferred + + call assert_equal('', glob('Xfuncdefer')) +endfunc + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim index b1ff392149..58dde3f1fe 100644 --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -2211,7 +2211,7 @@ def Test_script_local_in_legacy() END v9.CheckScriptFailure(lines, 'E476:', 1) - edit! Xfile + edit! Xslfile lines =<< trim END var edit: bool legacy edit diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 13f87cb8e5..b74a8eced2 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -1961,9 +1961,9 @@ enddef def Test_gettext() v9.CheckDefAndScriptFailure(['gettext(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - v9.CheckDefExecAndScriptFailure(['gettext("")'], 'E475: Invalid argument') + v9.CheckDefExecAndScriptFailure(['gettext("")'], 'E1175: Non-empty string required for argument 1') assert_equal('abc', gettext("abc")) - assert_fails('gettext("")', 'E475:') + assert_fails('gettext("")', 'E1175:') enddef def Test_getwininfo() diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index b9d8adb404..636769d3ab 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -931,11 +931,11 @@ func Test_command_modifier_confirm() let lines =<< trim END call setline(1, 'changed') def Getout() - confirm write Xfile + confirm write Xcmodfile enddef END call writefile(lines, 'Xconfirmscript') - call writefile(['empty'], 'Xfile') + call writefile(['empty'], 'Xcmodfile') let buf = RunVimInTerminal('-S Xconfirmscript', {'rows': 8}) call term_sendkeys(buf, ":call Getout()\n") call WaitForAssert({-> assert_match('(Y)es, \[N\]o: ', term_getline(buf, 8))}, 1000) @@ -945,9 +945,9 @@ func Test_command_modifier_confirm() call TermWait(buf) call StopVimInTerminal(buf) - call assert_equal(['changed'], readfile('Xfile')) - call delete('Xfile') - call delete('.Xfile.swp') " in case Vim was killed + call assert_equal(['changed'], readfile('Xcmodfile')) + call delete('Xcmodfile') + call delete('.Xcmodfile.swp') " in case Vim was killed call delete('Xconfirmscript') endfunc @@ -1065,13 +1065,13 @@ def Test_command_modifier_other() edit Xsomefile bwipe! - au BufNewFile Xfile g:readFile = 1 + au BufNewFile Xcmofile g:readFile = 1 g:readFile = 0 - edit Xfile + edit Xcmofile assert_equal(1, g:readFile) bwipe! g:readFile = 0 - noautocmd edit Xfile + noautocmd edit Xcmofile assert_equal(0, g:readFile) au! BufNewFile unlet g:readFile @@ -1407,7 +1407,7 @@ def Test_star_command() enddef def Test_cmd_argument_without_colon() - new Xfile + new Xawcfile setline(1, ['a', 'b', 'c', 'd']) write edit +3 % @@ -1415,7 +1415,7 @@ def Test_cmd_argument_without_colon() edit +/a % assert_equal(1, getcurpos()[1]) bwipe - delete('Xfile') + delete('Xawcfile') enddef def Test_ambiguous_user_cmd() @@ -1882,7 +1882,7 @@ def Test_redir_to_var() var text: string redir => text echo 'hello' - redir > Xfile + redir > Xnopfile redir END END v9.CheckDefFailure(lines, 'E1092:') @@ -2025,10 +2025,10 @@ enddef " Test for the 'previewpopup' option def Test_previewpopup() set previewpopup=height:10,width:60 - pedit Xfile + pedit Xppfile var id = popup_findpreview() assert_notequal(id, 0) - assert_match('Xfile', popup_getoptions(id).title) + assert_match('Xppfile', popup_getoptions(id).title) popup_clear() set previewpopup& enddef diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim index 12be156483..57b385bd50 100644 --- a/src/testdir/test_vim9_disassemble.vim +++ b/src/testdir/test_vim9_disassemble.vim @@ -2900,4 +2900,19 @@ def Test_disassemble_bitshift() '10 RETURN void', instr) enddef +def s:OneDefer() + defer delete("file") +enddef + +def Test_disassemble_defer() + var instr = execute('disassemble s:OneDefer') + assert_match('OneDefer\_s*' .. + 'defer delete("file")\_s*' .. + '\d PUSHFUNC "delete"\_s*' .. + '\d PUSHS "file"\_s*' .. + '\d DEFER 1 args\_s*' .. + '\d RETURN\_s*', + instr) +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 0fa74df259..c616e1890d 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -4272,6 +4272,36 @@ def Test_cexpr_errmsg_line_number() v9.CheckScriptFailure(lines, 'E777', 2) enddef +def AddDefer(s: string) + g:deferred->extend([s]) +enddef + +def DeferTwo() + g:deferred->extend(['in Two']) + for n in range(3) + defer g:AddDefer('two' .. n) + endfor + g:deferred->extend(['end Two']) +enddef + +def DeferOne() + g:deferred->extend(['in One']) + defer g:AddDefer('one') + g:DeferTwo() + g:deferred->extend(['end One']) + + writefile(['text'], 'XdeferFile') + defer delete('XdeferFile') +enddef + +def Test_defer() + g:deferred = [] + g:DeferOne() + assert_equal(['in One', 'in Two', 'end Two', 'two2', 'two1', 'two0', 'end One', 'one'], g:deferred) + unlet g:deferred + assert_equal('', glob('XdeferFile')) +enddef + " The following messes up syntax highlight, keep near the end. if has('python3') def Test_python3_command() diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 6ae2e2fea8..e844d4a082 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -1414,13 +1414,13 @@ def Test_import_in_charconvert() END v9.CheckScriptSuccess(lines) - writefile(['one', 'two'], 'Xfile') - new Xfile - write ++enc=ucase Xfile1 - assert_equal(['ONE', 'TWO'], readfile('Xfile1')) + writefile(['one', 'two'], 'Xiicfile') + new Xiicfile + write ++enc=ucase Xiicfile1 + assert_equal(['ONE', 'TWO'], readfile('Xiicfile1')) - delete('Xfile') - delete('Xfile1') + delete('Xiicfile') + delete('Xiicfile1') delete('Xconvert.vim') bwipe! set charconvert& @@ -1454,6 +1454,28 @@ def Run_Test_import_in_spellsuggest_expr() set nospell spellsuggest& verbose=0 enddef +def Test_import_in_lambda_method() + var lines =<< trim END + vim9script + export def Retarg(e: any): any + return e + enddef + END + writefile(lines, 'XexportRetarg.vim') + lines =<< trim END + vim9script + import './XexportRetarg.vim' + def Lambda(): string + var F = (x) => x->XexportRetarg.Retarg() + return F('arg') + enddef + assert_equal('arg', Lambda()) + END + v9.CheckScriptSuccess(lines) + + delete('XexportRetarg.vim') +enddef + def Test_export_shadows_global_function() mkdir('Xglobdir/autoload', 'p') var save_rtp = &rtp diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index bdefc8756a..aeee143297 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -968,11 +968,11 @@ def Test_cnext_works_in_catch() var lines =<< trim END vim9script au BufEnter * eval 1 + 2 - writefile(['text'], 'Xfile1') - writefile(['text'], 'Xfile2') + writefile(['text'], 'Xcncfile1') + writefile(['text'], 'Xcncfile2') var items = [ - {lnum: 1, filename: 'Xfile1', valid: true}, - {lnum: 1, filename: 'Xfile2', valid: true} + {lnum: 1, filename: 'Xcncfile1', valid: true}, + {lnum: 1, filename: 'Xcncfile2', valid: true} ] setqflist([], ' ', {items: items}) cwindow @@ -988,17 +988,17 @@ def Test_cnext_works_in_catch() CnextOrCfirst() CnextOrCfirst() - writefile([getqflist({idx: 0}).idx], 'Xresult') + writefile([getqflist({idx: 0}).idx], 'Xcncresult') qall END writefile(lines, 'XCatchCnext') g:RunVim([], [], '--clean -S XCatchCnext') - assert_equal(['1'], readfile('Xresult')) + assert_equal(['1'], readfile('Xcncresult')) - delete('Xfile1') - delete('Xfile2') + delete('Xcncfile1') + delete('Xcncfile2') delete('XCatchCnext') - delete('Xresult') + delete('Xcncresult') enddef def Test_throw_skipped() @@ -2708,7 +2708,7 @@ def Test_vim9_comment() '#{something', ], 'E1170:') - split Xfile + split Xv9cfile v9.CheckScriptSuccess([ 'vim9script', 'edit #something', @@ -3544,20 +3544,20 @@ def Test_restoring_cpo() mkdir('Xhome') var lines =<< trim END vim9script - writefile(['before: ' .. &cpo], 'Xresult') + writefile(['before: ' .. &cpo], 'Xrporesult') set cpo+=M - writefile(['after: ' .. &cpo], 'Xresult', 'a') + writefile(['after: ' .. &cpo], 'Xrporesult', 'a') END writefile(lines, 'Xhome/.vimrc') lines =<< trim END - call writefile(['later: ' .. &cpo], 'Xresult', 'a') + call writefile(['later: ' .. &cpo], 'Xrporesult', 'a') END writefile(lines, 'Xlegacy') lines =<< trim END vim9script - call writefile(['vim9: ' .. &cpo], 'Xresult', 'a') + call writefile(['vim9: ' .. &cpo], 'Xrporesult', 'a') qa END writefile(lines, 'Xvim9') @@ -3570,13 +3570,13 @@ def Test_restoring_cpo() 'before: aABceFs', 'after: aABceFsM', 'later: aABceFsM', - 'vim9: aABceFs'], readfile('Xresult')) + 'vim9: aABceFs'], readfile('Xrporesult')) $HOME = save_HOME delete('Xhome', 'rf') delete('Xlegacy') delete('Xvim9') - delete('Xresult') + delete('Xrporesult') endif enddef diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim index cde70bd1c6..31ce8293af 100644 --- a/src/testdir/test_visual.vim +++ b/src/testdir/test_visual.vim @@ -1472,7 +1472,7 @@ endfunc func Test_visual_area_adjusted_when_hiding() " The Visual area ended after the end of the line after :hide call setline(1, 'xxx') - vsplit Xfile + vsplit Xvaafile call setline(1, 'xxxxxxxx') norm! $o hid diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim index bea612f236..44fd646392 100644 --- a/src/testdir/test_window_cmd.vim +++ b/src/testdir/test_window_cmd.vim @@ -1083,12 +1083,12 @@ func Run_noroom_for_newwindow_test(dir_arg) endtry endwhile - call writefile(['first', 'second', 'third'], 'Xfile1') - call writefile([], 'Xfile2') - call writefile([], 'Xfile3') + call writefile(['first', 'second', 'third'], 'Xnorfile1') + call writefile([], 'Xnorfile2') + call writefile([], 'Xnorfile3') " Argument list related commands - args Xfile1 Xfile2 Xfile3 + args Xnorfile1 Xnorfile2 Xnorfile3 next for cmd in ['sargument 2', 'snext', 'sprevious', 'sNext', 'srewind', \ 'sfirst', 'slast'] @@ -1099,13 +1099,13 @@ func Run_noroom_for_newwindow_test(dir_arg) " Buffer related commands set modified hide enew - for cmd in ['sbuffer Xfile1', 'sbnext', 'sbprevious', 'sbNext', 'sbrewind', + for cmd in ['sbuffer Xnorfile1', 'sbnext', 'sbprevious', 'sbNext', 'sbrewind', \ 'sbfirst', 'sblast', 'sball', 'sbmodified', 'sunhide'] call assert_fails(dir .. cmd, 'E36:') endfor " Window related commands - for cmd in ['split', 'split Xfile2', 'new', 'new Xfile3', 'sview Xfile1', + for cmd in ['split', 'split Xnorfile2', 'new', 'new Xnorfile3', 'sview Xnorfile1', \ 'sfind runtest.vim'] call assert_fails(dir .. cmd, 'E36:') endfor @@ -1128,7 +1128,7 @@ func Run_noroom_for_newwindow_test(dir_arg) call assert_fails(dir .. 'lopen', 'E36:') " Preview window - call assert_fails(dir .. 'pedit Xfile2', 'E36:') + call assert_fails(dir .. 'pedit Xnorfile2', 'E36:') call setline(1, 'abc') call assert_fails(dir .. 'psearch abc', 'E36:') endif @@ -1136,15 +1136,15 @@ func Run_noroom_for_newwindow_test(dir_arg) " Window commands (CTRL-W ^ and CTRL-W f) if a:dir_arg == 'h' call assert_fails('call feedkeys("\^", "xt")', 'E36:') - call setline(1, 'Xfile1') + call setline(1, 'Xnorfile1') call assert_fails('call feedkeys("gg\f", "xt")', 'E36:') endif enew! " Tag commands (:stag, :stselect and :stjump) call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", - \ "second\tXfile1\t2", - \ "third\tXfile1\t3",], + \ "second\tXnorfile1\t2", + \ "third\tXnorfile1\t3",], \ 'Xtags') set tags=Xtags call assert_fails(dir .. 'stag second', 'E36:') @@ -1166,9 +1166,9 @@ func Run_noroom_for_newwindow_test(dir_arg) endif %bwipe! - call delete('Xfile1') - call delete('Xfile2') - call delete('Xfile3') + call delete('Xnorfile1') + call delete('Xnorfile2') + call delete('Xnorfile3') only endfunc @@ -1387,16 +1387,16 @@ endfunc " window to another. func Test_close_dest_window() split - edit Xfile + edit Xdstfile " Test for BufLeave augroup T1 au! - au BufLeave Xfile $wincmd c + au BufLeave Xdstfile $wincmd c augroup END wincmd b call assert_equal(1, winnr('$')) - call assert_equal('Xfile', @%) + call assert_equal('Xdstfile', @%) augroup T1 au! augroup END @@ -1410,7 +1410,7 @@ func Test_close_dest_window() augroup END wincmd t call assert_equal(1, winnr('$')) - call assert_equal('Xfile', @%) + call assert_equal('Xdstfile', @%) augroup T1 au! augroup END @@ -1595,12 +1595,12 @@ func Test_window_alloc_failure() call assert_fails('split', 'E342:') call assert_equal(1, winnr('$')) - edit Xfile1 - edit Xfile2 + edit Xwaffile1 + edit Xwaffile2 call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0) - call assert_fails('sb Xfile1', 'E342:') + call assert_fails('sb Xwaffile1', 'E342:') call assert_equal(1, winnr('$')) - call assert_equal('Xfile2', @%) + call assert_equal('Xwaffile2', @%) %bw! " FIXME: The following test crashes Vim diff --git a/src/testdir/test_writefile.vim b/src/testdir/test_writefile.vim index 92112f85e1..dddc5c9539 100644 --- a/src/testdir/test_writefile.vim +++ b/src/testdir/test_writefile.vim @@ -18,7 +18,7 @@ func Test_writefile() call assert_equal("vimmers", l[4]) call delete(f) - call assert_fails('call writefile("text", "Xfile")', 'E475: Invalid argument: writefile() first argument must be a List or a Blob') + call assert_fails('call writefile("text", "Xwffile")', 'E475: Invalid argument: writefile() first argument must be a List or a Blob') endfunc func Test_writefile_ignore_regexp_error() @@ -27,17 +27,17 @@ func Test_writefile_ignore_regexp_error() endfunc func Test_writefile_fails_gently() - call assert_fails('call writefile(["test"], "Xfile", [])', 'E730:') - call assert_false(filereadable("Xfile")) - call delete("Xfile") + call assert_fails('call writefile(["test"], "Xwffile", [])', 'E730:') + call assert_false(filereadable("Xwffile")) + call delete("Xwffile") - call assert_fails('call writefile(["test", [], [], [], "tset"], "Xfile")', 'E730:') - call assert_false(filereadable("Xfile")) - call delete("Xfile") + call assert_fails('call writefile(["test", [], [], [], "tset"], "Xwffile")', 'E730:') + call assert_false(filereadable("Xwffile")) + call delete("Xwffile") - call assert_fails('call writefile([], "Xfile", [])', 'E730:') - call assert_false(filereadable("Xfile")) - call delete("Xfile") + call assert_fails('call writefile([], "Xwffile", [])', 'E730:') + call assert_false(filereadable("Xwffile")) + call delete("Xwffile") call assert_fails('call writefile([], [])', 'E730:') endfunc @@ -52,35 +52,35 @@ func Test_writefile_fails_conversion() set nobackup nowritebackup backupdir=. backupskip= new let contents = ["line one", "line two"] - call writefile(contents, 'Xfile') - edit Xfile + call writefile(contents, 'Xwfcfile') + edit Xwfcfile call setline(1, ["first line", "cannot convert \u010b", "third line"]) call assert_fails('write ++enc=cp932', 'E513:') - call assert_equal(contents, readfile('Xfile')) + call assert_equal(contents, readfile('Xwfcfile')) " With 'backupcopy' set, if there is a conversion error, the backup file is " still created. set backupcopy=yes writebackup& backup& - call delete('Xfile' .. &backupext) + call delete('Xwfcfile' .. &backupext) call assert_fails('write ++enc=cp932', 'E513:') - call assert_equal(contents, readfile('Xfile')) - call assert_equal(contents, readfile('Xfile' .. &backupext)) + call assert_equal(contents, readfile('Xwfcfile')) + call assert_equal(contents, readfile('Xwfcfile' .. &backupext)) set backupcopy& %bw! " Conversion error during write new call setline(1, ["\U10000000"]) - let output = execute('write! ++enc=utf-16 Xfile') + let output = execute('write! ++enc=utf-16 Xwfcfile') call assert_match('CONVERSION ERROR', output) - let output = execute('write! ++enc=ucs-2 Xfile') + let output = execute('write! ++enc=ucs-2 Xwfcfile') call assert_match('CONVERSION ERROR', output) - call delete('Xfilz~') - call delete('Xfily~') + call delete('Xwfcfilz~') + call delete('Xwfcfily~') %bw! - call delete('Xfile') - call delete('Xfile' .. &backupext) + call delete('Xwfcfile') + call delete('Xwfcfile' .. &backupext) bwipe! set backup& writebackup& backupdir&vim backupskip&vim endfunc @@ -94,16 +94,16 @@ func Test_writefile_fails_conversion2() " but then the backup file must remain set nobackup writebackup backupdir=. backupskip= let contents = ["line one", "line two"] - call writefile(contents, 'Xfile_conversion_err') - edit Xfile_conversion_err + call writefile(contents, 'Xwf2file_conversion_err') + edit Xwf2file_conversion_err call setline(1, ["first line", "cannot convert \u010b", "third line"]) set fileencoding=latin1 let output = execute('write') call assert_match('CONVERSION ERROR', output) - call assert_equal(contents, readfile('Xfile_conversion_err~')) + call assert_equal(contents, readfile('Xwf2file_conversion_err~')) - call delete('Xfile_conversion_err') - call delete('Xfile_conversion_err~') + call delete('Xwf2file_conversion_err') + call delete('Xwf2file_conversion_err~') bwipe! set backup& writebackup& backupdir&vim backupskip&vim endfunc @@ -117,7 +117,7 @@ func Test_write_quit_split() augroup testgroup autocmd BufWritePre * split augroup END - e! Xfile + e! Xwqsfile call setline(1, 'nothing') wq @@ -130,13 +130,13 @@ func Test_write_quit_split() unlet g:flag endif au! testgroup - bwipe Xfile - call delete('Xfile') + bwipe Xwqsfile + call delete('Xwqsfile') endfunc func Test_nowrite_quit_split() " Prevent exiting by opening a help window. - e! Xfile + e! Xnqsfile help wincmd w exe winnr() . 'q' @@ -149,7 +149,7 @@ func Test_nowrite_quit_split() call assert_equal(1, g:flag) unlet g:flag endif - bwipe Xfile + bwipe Xnqsfile endfunc func Test_writefile_sync_arg() @@ -213,23 +213,23 @@ func Test_write_pipe_to_cmd() CheckUnix new call setline(1, ['L1', 'L2', 'L3', 'L4']) - 2,3w !cat > Xfile - call assert_equal(['L2', 'L3'], readfile('Xfile')) + 2,3w !cat > Xptfile + call assert_equal(['L2', 'L3'], readfile('Xptfile')) close! - call delete('Xfile') + call delete('Xptfile') endfunc " Test for :saveas func Test_saveas() call assert_fails('saveas', 'E471:') - call writefile(['L1'], 'Xfile') - new Xfile + call writefile(['L1'], 'Xsafile') + new Xsafile new call setline(1, ['L1']) - call assert_fails('saveas Xfile', 'E139:') + call assert_fails('saveas Xsafile', 'E139:') close! enew | only - call delete('Xfile') + call delete('Xsafile') " :saveas should detect and set the file type. syntax on @@ -242,8 +242,8 @@ endfunc func Test_write_errors() " Test for writing partial buffer - call writefile(['L1', 'L2', 'L3'], 'Xfile') - new Xfile + call writefile(['L1', 'L2', 'L3'], 'Xwefile') + new Xwefile call assert_fails('1,2write', 'E140:') close! @@ -263,24 +263,24 @@ func Test_write_errors() enew! " Test for writing a 'readonly' file - new Xfile + new Xwefile set readonly call assert_fails('write', 'E45:') close " Test for writing to a read-only file - new Xfile - call setfperm('Xfile', 'r--r--r--') + new Xwefile + call setfperm('Xwefile', 'r--r--r--') call assert_fails('write', 'E505:') - call setfperm('Xfile', 'rw-rw-rw-') + call setfperm('Xwefile', 'rw-rw-rw-') close - call delete('Xfile') + call delete('Xwefile') - call writefile(test_null_list(), 'Xfile') - call assert_false(filereadable('Xfile')) - call writefile(test_null_blob(), 'Xfile') - call assert_false(filereadable('Xfile')) + call writefile(test_null_list(), 'Xwefile') + call assert_false(filereadable('Xwefile')) + call writefile(test_null_blob(), 'Xwefile') + call assert_false(filereadable('Xwefile')) call assert_fails('call writefile([], "")', 'E482:') " very long file name @@ -305,9 +305,9 @@ func Test_write_file_mtime() CheckRunVimInTerminal " First read the file into a buffer - call writefile(["Line1", "Line2"], 'Xfile') - let old_ftime = getftime('Xfile') - let buf = RunVimInTerminal('Xfile', #{rows : 10}) + call writefile(["Line1", "Line2"], 'Xwfmfile') + let old_ftime = getftime('Xwfmfile') + let buf = RunVimInTerminal('Xwfmfile', #{rows : 10}) call TermWait(buf) call term_sendkeys(buf, ":set noswapfile\") call TermWait(buf) @@ -316,12 +316,12 @@ func Test_write_file_mtime() " different. Note that on Linux/Unix, the file is considered modified " outside, only if the difference is 2 seconds or more sleep 1 - call writefile(["Line3", "Line4"], 'Xfile') - let new_ftime = getftime('Xfile') + call writefile(["Line3", "Line4"], 'Xwfmfile') + let new_ftime = getftime('Xwfmfile') while new_ftime - old_ftime < 2 sleep 100m - call writefile(["Line3", "Line4"], 'Xfile') - let new_ftime = getftime('Xfile') + call writefile(["Line3", "Line4"], 'Xwfmfile') + let new_ftime = getftime('Xwfmfile') endwhile " Try to overwrite the file and check for the prompt @@ -332,24 +332,24 @@ func Test_write_file_mtime() \ term_getline(buf, 10)) call term_sendkeys(buf, "n\") call TermWait(buf) - call assert_equal(new_ftime, getftime('Xfile')) + call assert_equal(new_ftime, getftime('Xwfmfile')) call term_sendkeys(buf, ":w\") call TermWait(buf) call term_sendkeys(buf, "y\") call TermWait(buf) - call WaitForAssert({-> assert_equal('Line2', readfile('Xfile')[1])}) + call WaitForAssert({-> assert_equal('Line2', readfile('Xwfmfile')[1])}) " clean up call StopVimInTerminal(buf) - call delete('Xfile') + call delete('Xwfmfile') endfunc " Test for an autocmd unloading a buffer during a write command func Test_write_autocmd_unloadbuf_lockmark() augroup WriteTest - autocmd BufWritePre Xfile enew | write + autocmd BufWritePre Xwaufile enew | write augroup END - e Xfile + e Xwaufile call assert_fails('lockmarks write', ['E32:', 'E203:']) augroup WriteTest au! @@ -359,7 +359,7 @@ endfunc " Test for writing a buffer with 'acwrite' but without autocmds func Test_write_acwrite_error() - new Xfile + new Xwaefile call setline(1, ['line1', 'line2', 'line3']) set buftype=acwrite call assert_fails('write', 'E676:') @@ -370,35 +370,35 @@ endfunc " Test for adding and removing lines from an autocmd when writing a buffer func Test_write_autocmd_add_remove_lines() - new Xfile + new Xwaafile call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) " Autocmd deleting lines from the file when writing a partial file augroup WriteTest2 au! - autocmd FileWritePre Xfile 1,2d + autocmd FileWritePre Xwaafile 1,2d augroup END call assert_fails('2,3w!', 'E204:') " Autocmd adding lines to a file when writing a partial file augroup WriteTest2 au! - autocmd FileWritePre Xfile call append(0, ['xxx', 'yyy']) + autocmd FileWritePre Xwaafile call append(0, ['xxx', 'yyy']) augroup END %d call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) 1,2w! - call assert_equal(['xxx', 'yyy', 'aaa', 'bbb'], readfile('Xfile')) + call assert_equal(['xxx', 'yyy', 'aaa', 'bbb'], readfile('Xwaafile')) " Autocmd deleting lines from the file when writing the whole file augroup WriteTest2 au! - autocmd BufWritePre Xfile 1,2d + autocmd BufWritePre Xwaafile 1,2d augroup END %d call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) w - call assert_equal(['ccc', 'ddd'], readfile('Xfile')) + call assert_equal(['ccc', 'ddd'], readfile('Xwaafile')) augroup WriteTest2 au! @@ -406,14 +406,14 @@ func Test_write_autocmd_add_remove_lines() augroup! WriteTest2 close! - call delete('Xfile') + call delete('Xwaafile') endfunc " Test for writing to a readonly file func Test_write_readonly() - call writefile([], 'Xfile') - call setfperm('Xfile', "r--------") - edit Xfile + call writefile([], 'Xwrofile') + call setfperm('Xwrofile', "r--------") + edit Xwrofile set noreadonly backupskip= call assert_fails('write', 'E505:') let save_cpo = &cpo @@ -422,11 +422,11 @@ func Test_write_readonly() let &cpo = save_cpo call setline(1, ['line1']) write! - call assert_equal(['line1'], readfile('Xfile')) + call assert_equal(['line1'], readfile('Xwrofile')) " Auto-saving a readonly file should fail with 'autowriteall' %bw! - e Xfile + e Xwrofile set noreadonly autowriteall call setline(1, ['aaaa']) call assert_fails('n', 'E505:') @@ -436,39 +436,39 @@ func Test_write_readonly() set autowriteall& set backupskip& - call delete('Xfile') + call delete('Xwrofile') %bw! endfunc " Test for 'patchmode' func Test_patchmode() - call writefile(['one'], 'Xfile') + call writefile(['one'], 'Xpafile') set patchmode=.orig nobackup backupskip= writebackup - new Xfile + new Xpafile call setline(1, 'two') " first write should create the .orig file write - call assert_equal(['one'], readfile('Xfile.orig')) + call assert_equal(['one'], readfile('Xpafile.orig')) call setline(1, 'three') " subsequent writes should not create/modify the .orig file write - call assert_equal(['one'], readfile('Xfile.orig')) + call assert_equal(['one'], readfile('Xpafile.orig')) " use 'patchmode' with 'nobackup' and 'nowritebackup' to create an empty " original file - call delete('Xfile') - call delete('Xfile.orig') + call delete('Xpafile') + call delete('Xpafile.orig') %bw! set patchmode=.orig nobackup nowritebackup - edit Xfile + edit Xpafile call setline(1, ['xxx']) write - call assert_equal(['xxx'], readfile('Xfile')) - call assert_equal([], readfile('Xfile.orig')) + call assert_equal(['xxx'], readfile('Xpafile')) + call assert_equal([], readfile('Xpafile.orig')) set patchmode& backup& backupskip& writebackup& - call delete('Xfile') - call delete('Xfile.orig') + call delete('Xpafile') + call delete('Xpafile.orig') endfunc " Test for writing to a file in a readonly directory @@ -500,7 +500,7 @@ endfunc func Test_write_invalid_encoding() new call setline(1, 'abc') - call assert_fails('write ++enc=axbyc Xfile', 'E213:') + call assert_fails('write ++enc=axbyc Xiefile', 'E213:') close! endfunc @@ -515,101 +515,101 @@ func Test_write_file_encoding() 2 cp1251 text: Vim version 6.2. : 1970 Jan 01 3 cp866 text: Vim version 6.2. ᫥ : 1970 Jan 01 END - call writefile(text, 'Xfile') - edit Xfile + call writefile(text, 'Xwfefile') + edit Xwfefile " write tests: " combine three values for 'encoding' with three values for 'fileencoding' " also write files for read tests call cursor(1, 1) set encoding=utf-8 - .w! ++enc=utf-8 Xtest - .w ++enc=cp1251 >> Xtest - .w ++enc=cp866 >> Xtest + .w! ++enc=utf-8 Xwfetest + .w ++enc=cp1251 >> Xwfetest + .w ++enc=cp866 >> Xwfetest .w! ++enc=utf-8 Xutf8 let expected =<< trim END 1 utf-8 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 1 utf-8 text: Vim version 6.2. : 1970 Jan 01 1 utf-8 text: Vim version 6.2. ᫥ : 1970 Jan 01 END - call assert_equal(expected, readfile('Xtest')) + call assert_equal(expected, readfile('Xwfetest')) call cursor(2, 1) set encoding=cp1251 - .w! ++enc=utf-8 Xtest - .w ++enc=cp1251 >> Xtest - .w ++enc=cp866 >> Xtest + .w! ++enc=utf-8 Xwfetest + .w ++enc=cp1251 >> Xwfetest + .w ++enc=cp866 >> Xwfetest .w! ++enc=cp1251 Xcp1251 let expected =<< trim END 2 cp1251 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 2 cp1251 text: Vim version 6.2. : 1970 Jan 01 2 cp1251 text: Vim version 6.2. ᫥ : 1970 Jan 01 END - call assert_equal(expected, readfile('Xtest')) + call assert_equal(expected, readfile('Xwfetest')) call cursor(3, 1) set encoding=cp866 - .w! ++enc=utf-8 Xtest - .w ++enc=cp1251 >> Xtest - .w ++enc=cp866 >> Xtest + .w! ++enc=utf-8 Xwfetest + .w ++enc=cp1251 >> Xwfetest + .w ++enc=cp866 >> Xwfetest .w! ++enc=cp866 Xcp866 let expected =<< trim END 3 cp866 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 3 cp866 text: Vim version 6.2. : 1970 Jan 01 3 cp866 text: Vim version 6.2. ᫥ : 1970 Jan 01 END - call assert_equal(expected, readfile('Xtest')) + call assert_equal(expected, readfile('Xwfetest')) " read three 'fileencoding's with utf-8 'encoding' set encoding=utf-8 fencs=utf-8,cp1251 e Xutf8 - .w! ++enc=utf-8 Xtest + .w! ++enc=utf-8 Xwfetest e Xcp1251 - .w ++enc=utf-8 >> Xtest + .w ++enc=utf-8 >> Xwfetest set fencs=utf-8,cp866 e Xcp866 - .w ++enc=utf-8 >> Xtest + .w ++enc=utf-8 >> Xwfetest let expected =<< trim END 1 utf-8 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 2 cp1251 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 3 cp866 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 END - call assert_equal(expected, readfile('Xtest')) + call assert_equal(expected, readfile('Xwfetest')) " read three 'fileencoding's with cp1251 'encoding' set encoding=utf-8 fencs=utf-8,cp1251 e Xutf8 - .w! ++enc=cp1251 Xtest + .w! ++enc=cp1251 Xwfetest e Xcp1251 - .w ++enc=cp1251 >> Xtest + .w ++enc=cp1251 >> Xwfetest set fencs=utf-8,cp866 e Xcp866 - .w ++enc=cp1251 >> Xtest + .w ++enc=cp1251 >> Xwfetest let expected =<< trim END 1 utf-8 text: Vim version 6.2. : 1970 Jan 01 2 cp1251 text: Vim version 6.2. : 1970 Jan 01 3 cp866 text: Vim version 6.2. : 1970 Jan 01 END - call assert_equal(expected, readfile('Xtest')) + call assert_equal(expected, readfile('Xwfetest')) " read three 'fileencoding's with cp866 'encoding' set encoding=cp866 fencs=utf-8,cp1251 e Xutf8 - .w! ++enc=cp866 Xtest + .w! ++enc=cp866 Xwfetest e Xcp1251 - .w ++enc=cp866 >> Xtest + .w ++enc=cp866 >> Xwfetest set fencs=utf-8,cp866 e Xcp866 - .w ++enc=cp866 >> Xtest + .w ++enc=cp866 >> Xwfetest let expected =<< trim END 1 utf-8 text: Vim version 6.2. ᫥ : 1970 Jan 01 2 cp1251 text: Vim version 6.2. ᫥ : 1970 Jan 01 3 cp866 text: Vim version 6.2. ᫥ : 1970 Jan 01 END - call assert_equal(expected, readfile('Xtest')) + call assert_equal(expected, readfile('Xwfetest')) - call delete('Xfile') - call delete('Xtest') + call delete('Xwfefile') + call delete('Xwfetest') call delete('Xutf8') call delete('Xcp1251') call delete('Xcp866') @@ -635,114 +635,114 @@ func Test_readwrite_file_with_bom() set cpoptions+=S " Check that editing a latin1 file doesn't see a BOM - call writefile(["\xFE\xFElatin-1"], 'Xtest1') - edit Xtest1 + call writefile(["\xFE\xFElatin-1"], 'Xrwtest1') + edit Xrwtest1 call assert_equal('latin1', &fileencoding) call assert_equal(0, &bomb) set fenc=latin1 - write Xfile2 - call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xfile2', 'b')) + write Xrwfile2 + call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xrwfile2', 'b')) set bomb fenc=latin1 - write Xtest3 - call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xtest3', 'b')) + write Xrwtest3 + call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xrwtest3', 'b')) set bomb& " Check utf-8 BOM %bw! - call writefile([utf8_bom .. "utf-8"], 'Xtest1') - edit! Xtest1 + call writefile([utf8_bom .. "utf-8"], 'Xrwtest1') + edit! Xrwtest1 call assert_equal('utf-8', &fileencoding) call assert_equal(1, &bomb) call assert_equal('utf-8', getline(1)) set fenc=latin1 - write! Xfile2 - call assert_equal(['utf-8', ''], readfile('Xfile2', 'b')) + write! Xrwfile2 + call assert_equal(['utf-8', ''], readfile('Xrwfile2', 'b')) set fenc=utf-8 - w! Xtest3 - call assert_equal([utf8_bom .. "utf-8", ''], readfile('Xtest3', 'b')) + w! Xrwtest3 + call assert_equal([utf8_bom .. "utf-8", ''], readfile('Xrwtest3', 'b')) " Check utf-8 with an error (will fall back to latin-1) %bw! - call writefile([utf8_bom .. "utf-8\x80err"], 'Xtest1') - edit! Xtest1 + call writefile([utf8_bom .. "utf-8\x80err"], 'Xrwtest1') + edit! Xrwtest1 call assert_equal('latin1', &fileencoding) call assert_equal(0, &bomb) call assert_equal("\xC3\xAF\xC2\xBB\xC2\xBFutf-8\xC2\x80err", getline(1)) set fenc=latin1 - write! Xfile2 - call assert_equal([utf8_bom .. "utf-8\x80err", ''], readfile('Xfile2', 'b')) + write! Xrwfile2 + call assert_equal([utf8_bom .. "utf-8\x80err", ''], readfile('Xrwfile2', 'b')) set fenc=utf-8 - w! Xtest3 + w! Xrwtest3 call assert_equal(["\xC3\xAF\xC2\xBB\xC2\xBFutf-8\xC2\x80err", ''], - \ readfile('Xtest3', 'b')) + \ readfile('Xrwtest3', 'b')) " Check ucs-2 BOM %bw! - call writefile([utf16be_bom .. "\nu\nc\ns\n-\n2\n"], 'Xtest1') - edit! Xtest1 + call writefile([utf16be_bom .. "\nu\nc\ns\n-\n2\n"], 'Xrwtest1') + edit! Xrwtest1 call assert_equal('utf-16', &fileencoding) call assert_equal(1, &bomb) call assert_equal('ucs-2', getline(1)) set fenc=latin1 - write! Xfile2 - call assert_equal(["ucs-2", ''], readfile('Xfile2', 'b')) + write! Xrwfile2 + call assert_equal(["ucs-2", ''], readfile('Xrwfile2', 'b')) set fenc=ucs-2 - w! Xtest3 + w! Xrwtest3 call assert_equal([utf16be_bom .. "\nu\nc\ns\n-\n2\n", ''], - \ readfile('Xtest3', 'b')) + \ readfile('Xrwtest3', 'b')) " Check ucs-2le BOM %bw! - call writefile([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n"], 'Xtest1') + call writefile([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n"], 'Xrwtest1') " Need to add a NUL byte after the NL byte - call writefile(0z00, 'Xtest1', 'a') - edit! Xtest1 + call writefile(0z00, 'Xrwtest1', 'a') + edit! Xrwtest1 call assert_equal('utf-16le', &fileencoding) call assert_equal(1, &bomb) call assert_equal('ucs-2le', getline(1)) set fenc=latin1 - write! Xfile2 - call assert_equal(["ucs-2le", ''], readfile('Xfile2', 'b')) + write! Xrwfile2 + call assert_equal(["ucs-2le", ''], readfile('Xrwfile2', 'b')) set fenc=ucs-2le - w! Xtest3 + w! Xrwtest3 call assert_equal([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n", "\n"], - \ readfile('Xtest3', 'b')) + \ readfile('Xrwtest3', 'b')) " Check ucs-4 BOM %bw! - call writefile([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n"], 'Xtest1') - edit! Xtest1 + call writefile([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n"], 'Xrwtest1') + edit! Xrwtest1 call assert_equal('ucs-4', &fileencoding) call assert_equal(1, &bomb) call assert_equal('ucs-4', getline(1)) set fenc=latin1 - write! Xfile2 - call assert_equal(["ucs-4", ''], readfile('Xfile2', 'b')) + write! Xrwfile2 + call assert_equal(["ucs-4", ''], readfile('Xrwfile2', 'b')) set fenc=ucs-4 - w! Xtest3 - call assert_equal([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n", ''], readfile('Xtest3', 'b')) + w! Xrwtest3 + call assert_equal([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n", ''], readfile('Xrwtest3', 'b')) " Check ucs-4le BOM %bw! - call writefile([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n"], 'Xtest1') + call writefile([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n"], 'Xrwtest1') " Need to add three NUL bytes after the NL byte - call writefile(0z000000, 'Xtest1', 'a') - edit! Xtest1 + call writefile(0z000000, 'Xrwtest1', 'a') + edit! Xrwtest1 call assert_equal('ucs-4le', &fileencoding) call assert_equal(1, &bomb) call assert_equal('ucs-4le', getline(1)) set fenc=latin1 - write! Xfile2 - call assert_equal(["ucs-4le", ''], readfile('Xfile2', 'b')) + write! Xrwfile2 + call assert_equal(["ucs-4le", ''], readfile('Xrwfile2', 'b')) set fenc=ucs-4le - w! Xtest3 - call assert_equal([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n", "\n\n\n"], readfile('Xtest3', 'b')) + w! Xrwtest3 + call assert_equal([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n", "\n\n\n"], readfile('Xrwtest3', 'b')) set cpoptions-=S let &fileencoding = save_fileencoding - call delete('Xtest1') - call delete('Xfile2') - call delete('Xtest3') + call delete('Xrwtest1') + call delete('Xrwfile2') + call delete('Xrwtest3') %bw! endfunc @@ -773,83 +773,83 @@ func Test_backupcopy() " With the default 'backupcopy' setting, saving a symbolic link file " should not break the link. set backupcopy& - call writefile(['1111'], 'Xfile1') - silent !ln -s Xfile1 Xfile2 - new Xfile2 + call writefile(['1111'], 'Xbcfile1') + silent !ln -s Xbcfile1 Xbcfile2 + new Xbcfile2 call setline(1, ['2222']) write close - call assert_equal(['2222'], readfile('Xfile1')) - call assert_equal('Xfile1', resolve('Xfile2')) - call assert_equal('link', getftype('Xfile2')) - call delete('Xfile1') - call delete('Xfile2') + call assert_equal(['2222'], readfile('Xbcfile1')) + call assert_equal('Xbcfile1', resolve('Xbcfile2')) + call assert_equal('link', getftype('Xbcfile2')) + call delete('Xbcfile1') + call delete('Xbcfile2') " With the 'backupcopy' set to 'breaksymlink', saving a symbolic link file " should break the link. set backupcopy=yes,breaksymlink - call writefile(['1111'], 'Xfile1') - silent !ln -s Xfile1 Xfile2 - new Xfile2 + call writefile(['1111'], 'Xbcfile1') + silent !ln -s Xbcfile1 Xbcfile2 + new Xbcfile2 call setline(1, ['2222']) write close - call assert_equal(['1111'], readfile('Xfile1')) - call assert_equal(['2222'], readfile('Xfile2')) - call assert_equal('Xfile2', resolve('Xfile2')) - call assert_equal('file', getftype('Xfile2')) - call delete('Xfile1') - call delete('Xfile2') + call assert_equal(['1111'], readfile('Xbcfile1')) + call assert_equal(['2222'], readfile('Xbcfile2')) + call assert_equal('Xbcfile2', resolve('Xbcfile2')) + call assert_equal('file', getftype('Xbcfile2')) + call delete('Xbcfile1') + call delete('Xbcfile2') set backupcopy& " With the default 'backupcopy' setting, saving a hard link file " should not break the link. set backupcopy& - call writefile(['1111'], 'Xfile1') - silent !ln Xfile1 Xfile2 - new Xfile2 + call writefile(['1111'], 'Xbcfile1') + silent !ln Xbcfile1 Xbcfile2 + new Xbcfile2 call setline(1, ['2222']) write close - call assert_equal(['2222'], readfile('Xfile1')) - call delete('Xfile1') - call delete('Xfile2') + call assert_equal(['2222'], readfile('Xbcfile1')) + call delete('Xbcfile1') + call delete('Xbcfile2') " With the 'backupcopy' set to 'breaksymlink', saving a hard link file " should break the link. set backupcopy=yes,breakhardlink - call writefile(['1111'], 'Xfile1') - silent !ln Xfile1 Xfile2 - new Xfile2 + call writefile(['1111'], 'Xbcfile1') + silent !ln Xbcfile1 Xbcfile2 + new Xbcfile2 call setline(1, ['2222']) write - call assert_equal(['1111'], readfile('Xfile1')) - call assert_equal(['2222'], readfile('Xfile2')) - call delete('Xfile1') - call delete('Xfile2') + call assert_equal(['1111'], readfile('Xbcfile1')) + call assert_equal(['2222'], readfile('Xbcfile2')) + call delete('Xbcfile1') + call delete('Xbcfile2') " If a backup file is already present, then a slightly modified filename " should be used as the backup file. Try with 'backupcopy' set to 'yes' and " 'no'. %bw - call writefile(['aaaa'], 'Xfile') - call writefile(['bbbb'], 'Xfile.bak') + call writefile(['aaaa'], 'Xbcfile') + call writefile(['bbbb'], 'Xbcfile.bak') set backupcopy=yes backupext=.bak - new Xfile + new Xbcfile call setline(1, ['cccc']) write close - call assert_equal(['cccc'], readfile('Xfile')) - call assert_equal(['bbbb'], readfile('Xfile.bak')) + call assert_equal(['cccc'], readfile('Xbcfile')) + call assert_equal(['bbbb'], readfile('Xbcfile.bak')) set backupcopy=no backupext=.bak - new Xfile + new Xbcfile call setline(1, ['dddd']) write close - call assert_equal(['dddd'], readfile('Xfile')) - call assert_equal(['bbbb'], readfile('Xfile.bak')) - call delete('Xfile') - call delete('Xfile.bak') + call assert_equal(['dddd'], readfile('Xbcfile')) + call assert_equal(['bbbb'], readfile('Xbcfile.bak')) + call delete('Xbcfile') + call delete('Xbcfile.bak') " Write to a device file (in Unix-like systems) which cannot be backed up. if has('unix') @@ -880,10 +880,10 @@ endfunc func Test_write_utf16() new call setline(1, ["\U00010001"]) - write ++enc=utf-16 Xfile + write ++enc=utf-16 Xw16file bw! - call assert_equal(0zD800DC01, readfile('Xfile', 'B')[0:3]) - call delete('Xfile') + call assert_equal(0zD800DC01, readfile('Xw16file', 'B')[0:3]) + call delete('Xw16file') endfunc " Test for trying to save a backup file when the backup file is a symbolic @@ -893,24 +893,24 @@ func Test_write_backup_symlink() call mkdir('Xbackup') let save_backupdir = &backupdir set backupdir=.,./Xbackup - call writefile(['1111'], 'Xfile') - silent !ln -s Xfile Xfile.bak + call writefile(['1111'], 'Xwbsfile') + silent !ln -s Xwbsfile Xwbsfile.bak - new Xfile + new Xwbsfile set backup backupcopy=yes backupext=.bak write - call assert_equal('link', getftype('Xfile.bak')) - call assert_equal('Xfile', resolve('Xfile.bak')) + call assert_equal('link', getftype('Xwbsfile.bak')) + call assert_equal('Xwbsfile', resolve('Xwbsfile.bak')) " backup file should be created in the 'backup' directory if !has('bsd') " This check fails on FreeBSD - call assert_true(filereadable('./Xbackup/Xfile.bak')) + call assert_true(filereadable('./Xbackup/Xwbsfile.bak')) endif set backup& backupcopy& backupext& %bw - call delete('Xfile') - call delete('Xfile.bak') + call delete('Xwbsfile') + call delete('Xwbsfile.bak') call delete('Xbackup', 'rf') let &backupdir = save_backupdir endfunc @@ -918,19 +918,36 @@ endfunc " Test for ':write ++bin' and ':write ++nobin' func Test_write_binary_file() " create a file without an eol/eof character - call writefile(0z616161, 'Xfile1', 'b') - new Xfile1 - write ++bin Xfile2 - write ++nobin Xfile3 - call assert_equal(0z616161, readblob('Xfile2')) + call writefile(0z616161, 'Xwbfile1', 'b') + new Xwbfile1 + write ++bin Xwbfile2 + write ++nobin Xwbfile3 + call assert_equal(0z616161, readblob('Xwbfile2')) if has('win32') - call assert_equal(0z6161610D.0A, readblob('Xfile3')) + call assert_equal(0z6161610D.0A, readblob('Xwbfile3')) else - call assert_equal(0z6161610A, readblob('Xfile3')) + call assert_equal(0z6161610A, readblob('Xwbfile3')) endif - call delete('Xfile1') - call delete('Xfile2') - call delete('Xfile3') + call delete('Xwbfile1') + call delete('Xwbfile2') + call delete('Xwbfile3') +endfunc + +func DoWriteDefer() + call writefile(['some text'], 'XdeferDelete', 'D') + call assert_equal(['some text'], readfile('XdeferDelete')) +endfunc + +def DefWriteDefer() + writefile(['some text'], 'XdefdeferDelete', 'D') + assert_equal(['some text'], readfile('XdefdeferDelete')) +enddef + +func Test_write_with_deferred_delete() + call DoWriteDefer() + call assert_equal('', glob('XdeferDelete')) + call DefWriteDefer() + call assert_equal('', glob('XdefdeferDelete')) endfunc " Check that buffer is written before triggering QuitPre diff --git a/src/testing.c b/src/testing.c index 21eb9c18e6..8c682cf6bc 100644 --- a/src/testing.c +++ b/src/testing.c @@ -970,20 +970,17 @@ f_test_feedinput(typval_T *argvars, typval_T *rettv UNUSED) void f_test_getvalue(typval_T *argvars, typval_T *rettv) { - if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) + char_u *name; + + if (check_for_string_arg(argvars, 0) == FAIL) return; - if (argvars[0].v_type != VAR_STRING) - emsg(_(e_invalid_argument)); - else - { - char_u *name = tv_get_string(&argvars[0]); + name = tv_get_string(&argvars[0]); - if (STRCMP(name, (char_u *)"need_fileinfo") == 0) - rettv->vval.v_number = need_fileinfo; - else - semsg(_(e_invalid_argument_str), name); - } + if (STRCMP(name, (char_u *)"need_fileinfo") == 0) + rettv->vval.v_number = need_fileinfo; + else + semsg(_(e_invalid_argument_str), name); } /* @@ -994,17 +991,12 @@ f_test_option_not_set(typval_T *argvars, typval_T *rettv UNUSED) { char_u *name = (char_u *)""; - if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) + if (check_for_string_arg(argvars, 0) == FAIL) return; - if (argvars[0].v_type != VAR_STRING) - emsg(_(e_invalid_argument)); - else - { - name = tv_get_string(&argvars[0]); - if (reset_option_was_set(name) == FAIL) - semsg(_(e_invalid_argument_str), name); - } + name = tv_get_string(&argvars[0]); + if (reset_option_was_set(name) == FAIL) + semsg(_(e_invalid_argument_str), name); } /* @@ -1017,77 +1009,70 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED) int val; static int save_starting = -1; - if (in_vim9script() - && (check_for_string_arg(argvars, 0) == FAIL - || check_for_number_arg(argvars, 1) == FAIL)) + if (check_for_string_arg(argvars, 0) == FAIL + || check_for_number_arg(argvars, 1) == FAIL) return; - if (argvars[0].v_type != VAR_STRING - || (argvars[1].v_type) != VAR_NUMBER) - emsg(_(e_invalid_argument)); - else - { - name = tv_get_string(&argvars[0]); - val = (int)tv_get_number(&argvars[1]); + name = tv_get_string(&argvars[0]); + val = (int)tv_get_number(&argvars[1]); - if (STRCMP(name, (char_u *)"redraw") == 0) - disable_redraw_for_testing = val; - else if (STRCMP(name, (char_u *)"redraw_flag") == 0) - ignore_redraw_flag_for_testing = val; - else if (STRCMP(name, (char_u *)"char_avail") == 0) - disable_char_avail_for_testing = val; - else if (STRCMP(name, (char_u *)"starting") == 0) + if (STRCMP(name, (char_u *)"redraw") == 0) + disable_redraw_for_testing = val; + else if (STRCMP(name, (char_u *)"redraw_flag") == 0) + ignore_redraw_flag_for_testing = val; + else if (STRCMP(name, (char_u *)"char_avail") == 0) + disable_char_avail_for_testing = val; + else if (STRCMP(name, (char_u *)"starting") == 0) + { + if (val) { - if (val) - { - if (save_starting < 0) - save_starting = starting; - starting = 0; - } - else - { - starting = save_starting; - save_starting = -1; - } - } - else if (STRCMP(name, (char_u *)"nfa_fail") == 0) - nfa_fail_for_testing = val; - else if (STRCMP(name, (char_u *)"no_query_mouse") == 0) - no_query_mouse_for_testing = val; - else if (STRCMP(name, (char_u *)"no_wait_return") == 0) - no_wait_return = val; - else if (STRCMP(name, (char_u *)"ui_delay") == 0) - ui_delay_for_testing = val; - else if (STRCMP(name, (char_u *)"term_props") == 0) - reset_term_props_on_termresponse = val; - else if (STRCMP(name, (char_u *)"vterm_title") == 0) - disable_vterm_title_for_testing = val; - else if (STRCMP(name, (char_u *)"uptime") == 0) - override_sysinfo_uptime = val; - else if (STRCMP(name, (char_u *)"alloc_lines") == 0) - ml_get_alloc_lines = val; - else if (STRCMP(name, (char_u *)"autoload") == 0) - override_autoload = val; - else if (STRCMP(name, (char_u *)"ALL") == 0) - { - disable_char_avail_for_testing = FALSE; - disable_redraw_for_testing = FALSE; - ignore_redraw_flag_for_testing = FALSE; - nfa_fail_for_testing = FALSE; - no_query_mouse_for_testing = FALSE; - ui_delay_for_testing = 0; - reset_term_props_on_termresponse = FALSE; - override_sysinfo_uptime = -1; - // ml_get_alloc_lines is not reset by "ALL" - if (save_starting >= 0) - { - starting = save_starting; - save_starting = -1; - } + if (save_starting < 0) + save_starting = starting; + starting = 0; } else - semsg(_(e_invalid_argument_str), name); + { + starting = save_starting; + save_starting = -1; + } } + else if (STRCMP(name, (char_u *)"nfa_fail") == 0) + nfa_fail_for_testing = val; + else if (STRCMP(name, (char_u *)"no_query_mouse") == 0) + no_query_mouse_for_testing = val; + else if (STRCMP(name, (char_u *)"no_wait_return") == 0) + no_wait_return = val; + else if (STRCMP(name, (char_u *)"ui_delay") == 0) + ui_delay_for_testing = val; + else if (STRCMP(name, (char_u *)"term_props") == 0) + reset_term_props_on_termresponse = val; + else if (STRCMP(name, (char_u *)"vterm_title") == 0) + disable_vterm_title_for_testing = val; + else if (STRCMP(name, (char_u *)"uptime") == 0) + override_sysinfo_uptime = val; + else if (STRCMP(name, (char_u *)"alloc_lines") == 0) + ml_get_alloc_lines = val; + else if (STRCMP(name, (char_u *)"autoload") == 0) + override_autoload = val; + else if (STRCMP(name, (char_u *)"ALL") == 0) + { + disable_char_avail_for_testing = FALSE; + disable_redraw_for_testing = FALSE; + ignore_redraw_flag_for_testing = FALSE; + nfa_fail_for_testing = FALSE; + no_query_mouse_for_testing = FALSE; + ui_delay_for_testing = 0; + reset_term_props_on_termresponse = FALSE; + override_sysinfo_uptime = -1; + // ml_get_alloc_lines is not reset by "ALL" + if (save_starting >= 0) + { + starting = save_starting; + save_starting = -1; + } + } + else + semsg(_(e_invalid_argument_str), name); } /* @@ -1184,13 +1169,10 @@ f_test_garbagecollect_soon(typval_T *argvars UNUSED, typval_T *rettv UNUSED) void f_test_ignore_error(typval_T *argvars, typval_T *rettv UNUSED) { - if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) + if (check_for_string_arg(argvars, 0) == FAIL) return; - if (argvars[0].v_type != VAR_STRING) - emsg(_(e_invalid_argument)); - else - ignore_error_for_testing(tv_get_string(&argvars[0])); + ignore_error_for_testing(tv_get_string(&argvars[0])); } void @@ -1271,7 +1253,7 @@ f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED) || check_for_number_arg(argvars, 1) == FAIL)) return; - if (argvars[0].v_type != VAR_NUMBER || (argvars[1].v_type) != VAR_NUMBER) + if (argvars[0].v_type != VAR_NUMBER || argvars[1].v_type != VAR_NUMBER) { emsg(_(e_invalid_argument)); return; diff --git a/src/time.c b/src/time.c index d97c56e6c8..58337c9f65 100644 --- a/src/time.c +++ b/src/time.c @@ -805,19 +805,14 @@ f_timer_info(typval_T *argvars, typval_T *rettv) if (rettv_list_alloc(rettv) == FAIL) return; - if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL) + if (check_for_opt_number_arg(argvars, 0) == FAIL) return; if (argvars[0].v_type != VAR_UNKNOWN) { - if (argvars[0].v_type != VAR_NUMBER) - emsg(_(e_number_expected)); - else - { - timer = find_timer((int)tv_get_number(&argvars[0])); - if (timer != NULL) - add_timer_info(rettv, timer); - } + timer = find_timer((int)tv_get_number(&argvars[0])); + if (timer != NULL) + add_timer_info(rettv, timer); } else add_timer_info_all(rettv); @@ -909,14 +904,9 @@ f_timer_stop(typval_T *argvars, typval_T *rettv UNUSED) { timer_T *timer; - if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) + if (check_for_number_arg(argvars, 0) == FAIL) return; - if (argvars[0].v_type != VAR_NUMBER) - { - emsg(_(e_number_expected)); - return; - } timer = find_timer((int)tv_get_number(&argvars[0])); if (timer != NULL) stop_timer(timer); diff --git a/src/userfunc.c b/src/userfunc.c index 00c17b8c00..9ac681f202 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -311,9 +311,7 @@ get_function_args( // find the end of the expression (doesn't evaluate it) any_default = TRUE; - p = skipwhite(p) + 1; - whitep = p; - p = skipwhite(p); + p = skipwhite(np + 1); expr = p; if (eval1(&p, &rettv, NULL) != FAIL) { @@ -1728,44 +1726,37 @@ emsg_funcname(char *ermsg, char_u *name) } /* - * Allocate a variable for the result of a function. - * Return OK or FAIL. + * Get function arguments at "*arg" and advance it. + * Return them in "*argvars[MAX_FUNC_ARGS + 1]" and the count in "argcount". + * On failure FAIL is returned but the "argvars[argcount]" are still set. */ - int -get_func_tv( - char_u *name, // name of the function - int len, // length of "name" or -1 to use strlen() - typval_T *rettv, - char_u **arg, // argument, pointing to the '(' - evalarg_T *evalarg, // for line continuation - funcexe_T *funcexe) // various values + static int +get_func_arguments( + char_u **arg, + evalarg_T *evalarg, + int partial_argc, + typval_T *argvars, + int *argcount) { - char_u *argp; + char_u *argp = *arg; int ret = OK; - typval_T argvars[MAX_FUNC_ARGS + 1]; // vars for arguments - int argcount = 0; // number of arguments found int vim9script = in_vim9script(); int evaluate = evalarg == NULL ? FALSE : (evalarg->eval_flags & EVAL_EVALUATE); - /* - * Get the arguments. - */ - argp = *arg; - while (argcount < MAX_FUNC_ARGS - (funcexe->fe_partial == NULL ? 0 - : funcexe->fe_partial->pt_argc)) + while (*argcount < MAX_FUNC_ARGS - partial_argc) { // skip the '(' or ',' and possibly line breaks argp = skipwhite_and_linebreak(argp + 1, evalarg); if (*argp == ')' || *argp == ',' || *argp == NUL) break; - if (eval1(&argp, &argvars[argcount], evalarg) == FAIL) + if (eval1(&argp, &argvars[*argcount], evalarg) == FAIL) { ret = FAIL; break; } - ++argcount; + ++*argcount; // The comma should come right after the argument, but this wasn't // checked previously, thus only enforce it in Vim9 script. if (vim9script) @@ -1791,11 +1782,41 @@ get_func_tv( break; } } + argp = skipwhite_and_linebreak(argp, evalarg); if (*argp == ')') ++argp; else ret = FAIL; + *arg = argp; + return ret; +} + +/* + * Call a function and put the result in "rettv". + * Return OK or FAIL. + */ + int +get_func_tv( + char_u *name, // name of the function + int len, // length of "name" or -1 to use strlen() + typval_T *rettv, + char_u **arg, // argument, pointing to the '(' + evalarg_T *evalarg, // for line continuation + funcexe_T *funcexe) // various values +{ + char_u *argp; + int ret = OK; + typval_T argvars[MAX_FUNC_ARGS + 1]; // vars for arguments + int argcount = 0; // number of arguments found + int vim9script = in_vim9script(); + int evaluate = evalarg == NULL + ? FALSE : (evalarg->eval_flags & EVAL_EVALUATE); + + argp = *arg; + ret = get_func_arguments(&argp, evalarg, + (funcexe->fe_partial == NULL ? 0 : funcexe->fe_partial->pt_argc), + argvars, &argcount); if (ret == OK) { @@ -2884,6 +2905,9 @@ call_user_func( do_cmdline(NULL, get_func_line, (void *)fc, DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT); + // Invoke functions added with ":defer". + handle_defer(); + --RedrawingDisabled; // when the function was aborted because of an error, return -1 @@ -5457,8 +5481,189 @@ ex_return(exarg_T *eap) clear_evalarg(&evalarg, eap); } + static int +ex_call_inner( + exarg_T *eap, + char_u *name, + char_u **arg, + char_u *startarg, + funcexe_T *funcexe_init, + evalarg_T *evalarg) +{ + linenr_T lnum; + int doesrange; + typval_T rettv; + int failed = FALSE; + + /* + * When skipping, evaluate the function once, to find the end of the + * arguments. + * When the function takes a range, this is discovered after the first + * call, and the loop is broken. + */ + if (eap->skip) + { + ++emsg_skip; + lnum = eap->line2; // do it once, also with an invalid range + } + else + lnum = eap->line1; + for ( ; lnum <= eap->line2; ++lnum) + { + funcexe_T funcexe; + + if (!eap->skip && eap->addr_count > 0) + { + if (lnum > curbuf->b_ml.ml_line_count) + { + // If the function deleted lines or switched to another buffer + // the line number may become invalid. + emsg(_(e_invalid_range)); + break; + } + curwin->w_cursor.lnum = lnum; + curwin->w_cursor.col = 0; + curwin->w_cursor.coladd = 0; + } + *arg = startarg; + + funcexe = *funcexe_init; + funcexe.fe_doesrange = &doesrange; + rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this + if (get_func_tv(name, -1, &rettv, arg, evalarg, &funcexe) == FAIL) + { + failed = TRUE; + break; + } + if (has_watchexpr()) + dbg_check_breakpoint(eap); + + // Handle a function returning a Funcref, Dictionary or List. + if (handle_subscript(arg, NULL, &rettv, + eap->skip ? NULL : &EVALARG_EVALUATE, TRUE) == FAIL) + { + failed = TRUE; + break; + } + + clear_tv(&rettv); + if (doesrange || eap->skip) + break; + + // Stop when immediately aborting on error, or when an interrupt + // occurred or an exception was thrown but not caught. + // get_func_tv() returned OK, so that the check for trailing + // characters below is executed. + if (aborting()) + break; + } + if (eap->skip) + --emsg_skip; + return failed; +} + +/* + * Core part of ":defer func(arg)". "arg" points to the "(" and is advanced. + * Returns FAIL or OK. + */ + static int +ex_defer_inner(char_u *name, char_u **arg, evalarg_T *evalarg) +{ + typval_T argvars[MAX_FUNC_ARGS + 1]; // vars for arguments + int argcount = 0; // number of arguments found + + if (current_funccal == NULL) + { + semsg(_(e_str_not_inside_function), "defer"); + return FAIL; + } + if (get_func_arguments(arg, evalarg, FALSE, argvars, &argcount) == FAIL) + { + while (--argcount >= 0) + clear_tv(&argvars[argcount]); + return FAIL; + } + return add_defer(name, argcount, argvars); +} + +/* + * Add a deferred call for "name" with arguments "argvars[argcount]". + * Consumes "argvars[]". + * Caller must check that in_def_function() returns TRUE or current_funccal is + * not NULL. + * Returns OK or FAIL. + */ + int +add_defer(char_u *name, int argcount_arg, typval_T *argvars) +{ + char_u *saved_name = vim_strsave(name); + int argcount = argcount_arg; + defer_T *dr; + int ret = FAIL; + + if (saved_name == NULL) + goto theend; + if (in_def_function()) + { + if (add_defer_function(saved_name, argcount, argvars) == OK) + argcount = 0; + } + else + { + if (current_funccal->fc_defer.ga_itemsize == 0) + ga_init2(¤t_funccal->fc_defer, sizeof(defer_T), 10); + if (ga_grow(¤t_funccal->fc_defer, 1) == FAIL) + goto theend; + dr = ((defer_T *)current_funccal->fc_defer.ga_data) + + current_funccal->fc_defer.ga_len++; + dr->dr_name = saved_name; + dr->dr_argcount = argcount; + while (argcount > 0) + { + --argcount; + dr->dr_argvars[argcount] = argvars[argcount]; + } + } + ret = OK; + +theend: + while (--argcount >= 0) + clear_tv(&argvars[argcount]); + return ret; +} + +/* + * Invoked after a functions has finished: invoke ":defer" functions. + */ + void +handle_defer(void) +{ + int idx; + + for (idx = current_funccal->fc_defer.ga_len - 1; idx >= 0; --idx) + { + funcexe_T funcexe; + typval_T rettv; + defer_T *dr = ((defer_T *)current_funccal->fc_defer.ga_data) + idx; + int i; + + CLEAR_FIELD(funcexe); + funcexe.fe_evaluate = TRUE; + + rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this + call_func(dr->dr_name, -1, &rettv, + dr->dr_argcount, dr->dr_argvars, &funcexe); + clear_tv(&rettv); + vim_free(dr->dr_name); + for (i = dr->dr_argcount - 1; i >= 0; --i) + clear_tv(&dr->dr_argvars[i]); + } + ga_clear(¤t_funccal->fc_defer); +} + /* * ":1,25call func(arg1, arg2)" function call. + * ":defer func(arg1, arg2)" deferred function call. */ void ex_call(exarg_T *eap) @@ -5468,9 +5673,6 @@ ex_call(exarg_T *eap) char_u *name; char_u *tofree; int len; - typval_T rettv; - linenr_T lnum; - int doesrange; int failed = FALSE; funcdict_T fudi; partial_T *partial = NULL; @@ -5482,6 +5684,8 @@ ex_call(exarg_T *eap) fill_evalarg_from_eap(&evalarg, eap, eap->skip); if (eap->skip) { + typval_T rettv; + // trans_function_name() doesn't work well when skipping, use eval0() // instead to skip to any following command, e.g. for: // :if 0 | call dict.foo().bar() | endif @@ -5531,82 +5735,29 @@ ex_call(exarg_T *eap) goto end; } - /* - * When skipping, evaluate the function once, to find the end of the - * arguments. - * When the function takes a range, this is discovered after the first - * call, and the loop is broken. - */ - if (eap->skip) + if (eap->cmdidx == CMD_defer) { - ++emsg_skip; - lnum = eap->line2; // do it once, also with an invalid range + arg = startarg; + failed = ex_defer_inner(name, &arg, &evalarg) == FAIL; } else - lnum = eap->line1; - for ( ; lnum <= eap->line2; ++lnum) { funcexe_T funcexe; - if (!eap->skip && eap->addr_count > 0) - { - if (lnum > curbuf->b_ml.ml_line_count) - { - // If the function deleted lines or switched to another buffer - // the line number may become invalid. - emsg(_(e_invalid_range)); - break; - } - curwin->w_cursor.lnum = lnum; - curwin->w_cursor.col = 0; - curwin->w_cursor.coladd = 0; - } - arg = startarg; - CLEAR_FIELD(funcexe); - funcexe.fe_firstline = eap->line1; - funcexe.fe_lastline = eap->line2; - funcexe.fe_doesrange = &doesrange; - funcexe.fe_evaluate = !eap->skip; + funcexe.fe_check_type = type; funcexe.fe_partial = partial; funcexe.fe_selfdict = fudi.fd_dict; - funcexe.fe_check_type = type; + funcexe.fe_firstline = eap->line1; + funcexe.fe_lastline = eap->line2; funcexe.fe_found_var = found_var; - rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this - if (get_func_tv(name, -1, &rettv, &arg, &evalarg, &funcexe) == FAIL) - { - failed = TRUE; - break; - } - if (has_watchexpr()) - dbg_check_breakpoint(eap); - - // Handle a function returning a Funcref, Dictionary or List. - if (handle_subscript(&arg, NULL, &rettv, - eap->skip ? NULL : &EVALARG_EVALUATE, TRUE) == FAIL) - { - failed = TRUE; - break; - } - - clear_tv(&rettv); - if (doesrange || eap->skip) - break; - - // Stop when immediately aborting on error, or when an interrupt - // occurred or an exception was thrown but not caught. - // get_func_tv() returned OK, so that the check for trailing - // characters below is executed. - if (aborting()) - break; + funcexe.fe_evaluate = !eap->skip; + failed = ex_call_inner(eap, name, &arg, startarg, &funcexe, &evalarg); } - if (eap->skip) - --emsg_skip; // When inside :try we need to check for following "| catch" or "| endtry". // Not when there was an error, but do check if an exception was thrown. - if ((!aborting() || did_throw) - && (!failed || eap->cstack->cs_trylevel > 0)) + if ((!aborting() || did_throw) && (!failed || eap->cstack->cs_trylevel > 0)) { // Check for trailing illegal characters and a following command. arg = skipwhite(arg); diff --git a/src/version.c b/src/version.c index 841ecba1ce..0d8bfa31e7 100644 --- a/src/version.c +++ b/src/version.c @@ -254,12 +254,8 @@ static char *(features[]) = #else "-folding", #endif -#ifdef FEAT_FOOTER - "+footer", -#else "-footer", -#endif - // only interesting on Unix systems + // only interesting on Unix systems #if !defined(USE_SYSTEM) && defined(UNIX) "+fork()", #endif @@ -722,6 +718,60 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 381, +/**/ + 380, +/**/ + 379, +/**/ + 378, +/**/ + 377, +/**/ + 376, +/**/ + 375, +/**/ + 374, +/**/ + 373, +/**/ + 372, +/**/ + 371, +/**/ + 370, +/**/ + 369, +/**/ + 368, +/**/ + 367, +/**/ + 366, +/**/ + 365, +/**/ + 364, +/**/ + 363, +/**/ + 362, +/**/ + 361, +/**/ + 360, +/**/ + 359, +/**/ + 358, +/**/ + 357, +/**/ + 356, +/**/ + 355, /**/ 354, /**/ diff --git a/src/vim9.h b/src/vim9.h index b32dbeab44..22a3f3990e 100644 --- a/src/vim9.h +++ b/src/vim9.h @@ -113,6 +113,7 @@ typedef enum { ISN_FUNCREF, // push a function ref to dfunc isn_arg.funcref ISN_NEWFUNC, // create a global function from a lambda function ISN_DEF, // list functions + ISN_DEFER, // :defer argument count is isn_arg.number // expression operations ISN_JUMP, // jump if condition is matched isn_arg.jump @@ -419,6 +420,12 @@ typedef struct { int dbg_break_lnum; // first line to break after } debug_T; +// arguments to ISN_DEFER +typedef struct { + int defer_var_idx; // local variable index for defer list + int defer_argcount; // number of arguments +} deferins_T; + /* * Instruction */ @@ -468,6 +475,7 @@ struct isn_S { tobool_T tobool; getitem_T getitem; debug_T debug; + deferins_T defer; } isn_arg; }; @@ -498,6 +506,9 @@ struct dfunc_S { int df_varcount; // number of local variables int df_has_closure; // one if a closure was created + int df_defer_var_idx; // index of local variable that has a list + // of deferred function calls; zero if not + // set }; // Number of entries used by stack frame for a function call. @@ -735,6 +746,15 @@ struct cctx_S { // lhs_name is not NULL }; +/* + * List of special functions for "compile_arguments()". + */ +typedef enum { + CA_NOT_SPECIAL, + CA_SEARCHPAIR, // {skip} in searchpair() and searchpairpos() + CA_SUBSTITUTE, // {sub} in substitute(), when prefixed with \= +} ca_special_T; + // flags for typval2type() #define TVTT_DO_MEMBER 1 #define TVTT_MORE_SPECIFIC 2 // get most specific type for member diff --git a/src/vim9cmds.c b/src/vim9cmds.c index 4ad87bc264..c294d70a85 100644 --- a/src/vim9cmds.c +++ b/src/vim9cmds.c @@ -1654,6 +1654,9 @@ compile_throw(char_u *arg, cctx_T *cctx UNUSED) return p; } +/* + * Compile an expression or function call. + */ char_u * compile_eval(char_u *arg, cctx_T *cctx) { @@ -1681,6 +1684,82 @@ compile_eval(char_u *arg, cctx_T *cctx) return skipwhite(p); } +/* + * Get the local variable index for deferred function calls. + * Reserve it when not done already. + * Returns zero for failure. + */ + int +get_defer_var_idx(cctx_T *cctx) +{ + dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) + + cctx->ctx_ufunc->uf_dfunc_idx; + if (dfunc->df_defer_var_idx == 0) + { + lvar_T *lvar = reserve_local(cctx, (char_u *)"@defer@", 7, + TRUE, &t_list_any); + if (lvar == NULL) + return 0; + dfunc->df_defer_var_idx = lvar->lv_idx + 1; + } + return dfunc->df_defer_var_idx; +} + +/* + * Compile "defer func(arg)". + */ + char_u * +compile_defer(char_u *arg_start, cctx_T *cctx) +{ + char_u *p; + char_u *arg = arg_start; + int argcount = 0; + int defer_var_idx; + type_T *type; + int func_idx; + + // Get a funcref for the function name. + // TODO: better way to find the "(". + p = vim_strchr(arg, '('); + if (p == NULL) + { + semsg(_(e_missing_parenthesis_str), arg); + return NULL; + } + *p = NUL; + func_idx = find_internal_func(arg); + if (func_idx >= 0) + // TODO: better type + generate_PUSHFUNC(cctx, (char_u *)internal_func_name(func_idx), + &t_func_any, FALSE); + else if (compile_expr0(&arg, cctx) == FAIL) + return NULL; + *p = '('; + + // check for function type + type = get_type_on_stack(cctx, 0); + if (type->tt_type != VAR_FUNC) + { + emsg(_(e_function_name_required)); + return NULL; + } + + // compile the arguments + arg = skipwhite(p + 1); + if (compile_arguments(&arg, cctx, &argcount, CA_NOT_SPECIAL) == FAIL) + return NULL; + + // TODO: check argument count with "type" + + defer_var_idx = get_defer_var_idx(cctx); + if (defer_var_idx == 0) + return NULL; + if (generate_DEFER(cctx, defer_var_idx - 1, argcount) == FAIL) + return NULL; + + return skipwhite(arg); +} + /* * compile "echo expr" * compile "echomsg expr" diff --git a/src/vim9compile.c b/src/vim9compile.c index 20366752cf..02cbb25df5 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2243,9 +2243,9 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx) r = compile_expr0_ext(&p, cctx, &is_const); if (lhs.lhs_new_local) ++cctx->ctx_locals.ga_len; - if (r == FAIL) - goto theend; } + if (r == FAIL) + goto theend; } else if (semicolon && var_idx == var_count - 1) { @@ -2373,7 +2373,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx) r = generate_PUSHBLOB(cctx, blob_alloc()); break; case VAR_FUNC: - r = generate_PUSHFUNC(cctx, NULL, &t_func_void); + r = generate_PUSHFUNC(cctx, NULL, &t_func_void, TRUE); break; case VAR_LIST: r = generate_NEWLIST(cctx, 0, FALSE); @@ -2748,6 +2748,7 @@ compile_def_function( // Was compiled in this mode before: Free old instructions. delete_def_function_contents(dfunc, FALSE); ga_clear_strings(&dfunc->df_var_names); + dfunc->df_defer_var_idx = 0; } else { @@ -3249,6 +3250,10 @@ compile_def_function( line = compile_eval(p, &cctx); break; + case CMD_defer: + line = compile_defer(p, &cctx); + break; + case CMD_echo: case CMD_echon: case CMD_echoconsole: diff --git a/src/vim9execute.c b/src/vim9execute.c index a1311ee177..3194f872f4 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -101,9 +101,15 @@ struct ectx_S { static garray_T profile_info_ga = {0, 0, sizeof(profinfo_T), 20, NULL}; #endif +// Get pointer to item in the stack. +#define STACK_TV(idx) (((typval_T *)ectx->ec_stack.ga_data) + idx) + // Get pointer to item relative to the bottom of the stack, -1 is the last one. #define STACK_TV_BOT(idx) (((typval_T *)ectx->ec_stack.ga_data) + ectx->ec_stack.ga_len + (idx)) +// Get pointer to a local variable on the stack. Negative for arguments. +#define STACK_TV_VAR(idx) (((typval_T *)ectx->ec_stack.ga_data) + ectx->ec_frame_idx + STACK_FRAME_SIZE + idx) + void to_string_error(vartype_T vartype) { @@ -610,9 +616,6 @@ call_dfunc( return OK; } -// Get pointer to item in the stack. -#define STACK_TV(idx) (((typval_T *)ectx->ec_stack.ga_data) + idx) - // Double linked list of funcstack_T in use. static funcstack_T *first_funcstack = NULL; @@ -842,6 +845,155 @@ set_ref_in_funcstacks(int copyID) return FALSE; } +// Ugly static to avoid passing the execution context around through many +// layers. +static ectx_T *current_ectx = NULL; + +/* + * Return TRUE if currently executing a :def function. + * Can be used by builtin functions only. + */ + int +in_def_function(void) +{ + return current_ectx != NULL; +} + +/* + * Add an entry for a deferred function call to the currently executing + * function. + * Return the list or NULL when failed. + */ + static list_T * +add_defer_item(int var_idx, int argcount, ectx_T *ectx) +{ + typval_T *defer_tv = STACK_TV_VAR(var_idx); + list_T *defer_l; + list_T *l; + typval_T listval; + + if (defer_tv->v_type != VAR_LIST) + { + // first time, allocate the list + if (rettv_list_alloc(defer_tv) == FAIL) + return NULL; + } + defer_l = defer_tv->vval.v_list; + + l = list_alloc_with_items(argcount + 1); + if (l == NULL) + return NULL; + listval.v_type = VAR_LIST; + listval.vval.v_list = l; + listval.v_lock = 0; + if (list_insert_tv(defer_l, &listval, defer_l->lv_first) == FAIL) + { + vim_free(l); + return NULL; + } + + return l; +} + +/* + * Handle ISN_DEFER. Stack has a function reference and "argcount" arguments. + * The local variable that lists deferred functions is "var_idx". + * Returns OK or FAIL. + */ + static int +defer_command(int var_idx, int argcount, ectx_T *ectx) +{ + list_T *l = add_defer_item(var_idx, argcount, ectx); + int i; + typval_T *func_tv; + + if (l == NULL) + return FAIL; + + func_tv = STACK_TV_BOT(-argcount - 1); + // TODO: check type is a funcref + list_set_item(l, 0, func_tv); + + for (i = 1; i <= argcount; ++i) + list_set_item(l, i, STACK_TV_BOT(-argcount + i - 1)); + ectx->ec_stack.ga_len -= argcount + 1; + return OK; +} + +/* + * Add a deferred function "name" with one argument "arg_tv". + * Consumes "name", also on failure. + * Only to be called when in_def_function() returns TRUE. + */ + int +add_defer_function(char_u *name, int argcount, typval_T *argvars) +{ + dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) + + current_ectx->ec_dfunc_idx; + list_T *l; + typval_T func_tv; + int i; + + if (dfunc->df_defer_var_idx == 0) + { + iemsg("df_defer_var_idx is zero"); + vim_free(func_tv.vval.v_string); + return FAIL; + } + func_tv.v_type = VAR_FUNC; + func_tv.v_lock = 0; + func_tv.vval.v_string = name; + + l = add_defer_item(dfunc->df_defer_var_idx - 1, 1, current_ectx); + if (l == NULL) + { + vim_free(func_tv.vval.v_string); + return FAIL; + } + + list_set_item(l, 0, &func_tv); + for (i = 0; i < argcount; ++i) + list_set_item(l, i + 1, argvars + i); + return OK; +} + +/* + * Invoked when returning from a function: Invoke any deferred calls. + */ + static void +invoke_defer_funcs(ectx_T *ectx) +{ + dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) + + ectx->ec_dfunc_idx; + typval_T *defer_tv = STACK_TV_VAR(dfunc->df_defer_var_idx - 1); + listitem_T *li; + + if (defer_tv->v_type != VAR_LIST) + return; // no function added + for (li = defer_tv->vval.v_list->lv_first; li != NULL; li = li->li_next) + { + list_T *l = li->li_tv.vval.v_list; + typval_T rettv; + typval_T argvars[MAX_FUNC_ARGS]; + int i; + listitem_T *arg_li = l->lv_first; + funcexe_T funcexe; + + for (i = 0; i < l->lv_len - 1; ++i) + { + arg_li = arg_li->li_next; + argvars[i] = arg_li->li_tv; + } + + CLEAR_FIELD(funcexe); + funcexe.fe_evaluate = TRUE; + rettv.v_type = VAR_UNKNOWN; + (void)call_func(l->lv_first->li_tv.vval.v_string, -1, + &rettv, l->lv_len - 1, argvars, &funcexe); + clear_tv(&rettv); + } +} + /* * Return from the current function. */ @@ -876,6 +1028,9 @@ func_return(ectx_T *ectx) } #endif + if (dfunc->df_defer_var_idx > 0) + invoke_defer_funcs(ectx); + // No check for uf_refcount being zero, cannot think of a way that would // happen. --dfunc->df_ufunc->uf_calls; @@ -949,8 +1104,6 @@ func_return(ectx_T *ectx) return OK; } -#undef STACK_TV - /* * Prepare arguments and rettv for calling a builtin or user function. */ @@ -982,10 +1135,6 @@ call_prepare(int argcount, typval_T *argvars, ectx_T *ectx) return OK; } -// Ugly global to avoid passing the execution context around through many -// layers. -static ectx_T *current_ectx = NULL; - /* * Call a builtin function by index. */ @@ -1732,16 +1881,6 @@ typedef struct subs_expr_S { int subs_status; } subs_expr_T; -// Get pointer to item in the stack. -#define STACK_TV(idx) (((typval_T *)ectx->ec_stack.ga_data) + idx) - -// Get pointer to item at the bottom of the stack, -1 is the bottom. -#undef STACK_TV_BOT -#define STACK_TV_BOT(idx) (((typval_T *)ectx->ec_stack.ga_data) + ectx->ec_stack.ga_len + idx) - -// Get pointer to a local variable on the stack. Negative for arguments. -#define STACK_TV_VAR(idx) (((typval_T *)ectx->ec_stack.ga_data) + ectx->ec_frame_idx + STACK_FRAME_SIZE + idx) - // Set when calling do_debug(). static ectx_T *debug_context = NULL; static int debug_var_count; @@ -3670,6 +3809,13 @@ exec_instructions(ectx_T *ectx) } break; + // :defer func(arg) + case ISN_DEFER: + if (defer_command(iptr->isn_arg.defer.defer_var_idx, + iptr->isn_arg.defer.defer_argcount, ectx) == FAIL) + goto on_error; + break; + // return from a :def function call without a value case ISN_RETURN_VOID: if (GA_GROW_FAILS(&ectx->ec_stack, 1)) @@ -5024,13 +5170,21 @@ on_fatal_error: done: ret = OK; theend: + { + dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) + + ectx->ec_dfunc_idx; + + if (dfunc->df_defer_var_idx > 0) + invoke_defer_funcs(ectx); + } + dict_stack_clear(dict_stack_len_at_start); ectx->ec_trylevel_at_start = save_trylevel_at_start; return ret; } /* - * Execute the instructions from a VAR_INSTR typeval and put the result in + * Execute the instructions from a VAR_INSTR typval and put the result in * "rettv". * Return OK or FAIL. */ @@ -5903,6 +6057,10 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc) case ISN_PCALL_END: smsg("%s%4d PCALL end", pfx, current); break; + case ISN_DEFER: + smsg("%s%4d DEFER %d args", pfx, current, + (int)iptr->isn_arg.defer.defer_argcount); + break; case ISN_RETURN: smsg("%s%4d RETURN", pfx, current); break; diff --git a/src/vim9expr.c b/src/vim9expr.c index 370dce315c..a8d88a2f28 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -313,7 +313,7 @@ compile_load_scriptvar( // name. If a '(' follows it must be a function. Otherwise we // don't know, it can be "script.Func". if (cc == '(' || paren_follows_after_expr) - res = generate_PUSHFUNC(cctx, auto_name, &t_func_any); + res = generate_PUSHFUNC(cctx, auto_name, &t_func_any, TRUE); else res = generate_AUTOLOAD(cctx, auto_name, &t_any); vim_free(auto_name); @@ -329,7 +329,7 @@ compile_load_scriptvar( char_u sid_name[MAX_FUNC_NAME_LEN]; func_name_with_sid(exp_name, import->imp_sid, sid_name); - res = generate_PUSHFUNC(cctx, sid_name, &t_func_any); + res = generate_PUSHFUNC(cctx, sid_name, &t_func_any, TRUE); } else res = generate_OLDSCRIPT(cctx, ISN_LOADEXPORT, exp_name, @@ -353,7 +353,7 @@ compile_load_scriptvar( if (ufunc != NULL) { // function call or function reference - generate_PUSHFUNC(cctx, ufunc->uf_name, NULL); + generate_PUSHFUNC(cctx, ufunc->uf_name, NULL, TRUE); return OK; } return FAIL; @@ -387,7 +387,7 @@ generate_funcref(cctx_T *cctx, char_u *name, int has_g_prefix) if (func_needs_compiling(ufunc, compile_type) && compile_def_function(ufunc, TRUE, compile_type, NULL) == FAIL) return FAIL; - return generate_PUSHFUNC(cctx, ufunc->uf_name, ufunc->uf_func_type); + return generate_PUSHFUNC(cctx, ufunc->uf_name, ufunc->uf_func_type, TRUE); } /* @@ -609,20 +609,11 @@ compile_string(isn_T *isn, cctx_T *cctx, int str_offset) return OK; } -/* - * List of special functions for "compile_arguments". - */ -typedef enum { - CA_NOT_SPECIAL, - CA_SEARCHPAIR, // {skip} in searchpair() and searchpairpos() - CA_SUBSTITUTE, // {sub} in substitute(), when prefixed with \= -} ca_special_T; - /* * Compile the argument expressions. * "arg" points to just after the "(" and is advanced to after the ")" */ - static int + int compile_arguments( char_u **arg, cctx_T *cctx, @@ -842,6 +833,14 @@ compile_call( } } + if (STRCMP(name, "writefile") == 0 && argcount > 2) + { + // May have the "D" flag, reserve a variable for a deferred + // function call. + if (get_defer_var_idx(cctx) == 0) + idx = -1; + } + if (idx >= 0) res = generate_BCALL(cctx, idx, argcount, argcount_init == 1); } diff --git a/src/vim9instr.c b/src/vim9instr.c index a13516bbb2..34d4ae33f3 100644 --- a/src/vim9instr.c +++ b/src/vim9instr.c @@ -514,10 +514,8 @@ generate_2BOOL(cctx_T *cctx, int invert, int offset) int generate_COND2BOOL(cctx_T *cctx) { - isn_T *isn; - RETURN_OK_IF_SKIP(cctx); - if ((isn = generate_instr(cctx, ISN_COND2BOOL)) == NULL) + if (generate_instr(cctx, ISN_COND2BOOL) == NULL) return FAIL; // type becomes bool @@ -616,7 +614,7 @@ generate_tv_PUSH(cctx_T *cctx, typval_T *tv) case VAR_FUNC: if (tv->vval.v_string != NULL) iemsg("non-null function constant not supported"); - generate_PUSHFUNC(cctx, NULL, &t_func_unknown); + generate_PUSHFUNC(cctx, NULL, &t_func_unknown, TRUE); break; case VAR_PARTIAL: if (tv->vval.v_partial != NULL) @@ -741,13 +739,9 @@ generate_PUSHS(cctx_T *cctx, char_u **str) int generate_PUSHCHANNEL(cctx_T *cctx) { -#ifdef FEAT_JOB_CHANNEL - isn_T *isn; -#endif - RETURN_OK_IF_SKIP(cctx); #ifdef FEAT_JOB_CHANNEL - if ((isn = generate_instr_type(cctx, ISN_PUSHCHANNEL, &t_channel)) == NULL) + if (generate_instr_type(cctx, ISN_PUSHCHANNEL, &t_channel) == NULL) return FAIL; return OK; #else @@ -762,13 +756,9 @@ generate_PUSHCHANNEL(cctx_T *cctx) int generate_PUSHJOB(cctx_T *cctx) { -#ifdef FEAT_JOB_CHANNEL - isn_T *isn; -#endif - RETURN_OK_IF_SKIP(cctx); #ifdef FEAT_JOB_CHANNEL - if ((isn = generate_instr_type(cctx, ISN_PUSHJOB, &t_job)) == NULL) + if (generate_instr_type(cctx, ISN_PUSHJOB, &t_job) == NULL) return FAIL; return OK; #else @@ -796,9 +786,11 @@ generate_PUSHBLOB(cctx_T *cctx, blob_T *blob) /* * Generate an ISN_PUSHFUNC instruction with name "name". + * When "may_prefix" is TRUE prefix "g:" unless "name" is script-local or + * autoload. */ int -generate_PUSHFUNC(cctx_T *cctx, char_u *name, type_T *type) +generate_PUSHFUNC(cctx_T *cctx, char_u *name, type_T *type, int may_prefix) { isn_T *isn; char_u *funcname; @@ -808,7 +800,8 @@ generate_PUSHFUNC(cctx_T *cctx, char_u *name, type_T *type) return FAIL; if (name == NULL) funcname = NULL; - else if (*name == K_SPECIAL // script-local + else if (!may_prefix + || *name == K_SPECIAL // script-local || vim_strchr(name, AUTOLOAD_CHAR) != NULL) // autoload funcname = vim_strsave(name); else @@ -1064,10 +1057,8 @@ generate_UNLET(cctx_T *cctx, isntype_T isn_type, char_u *name, int forceit) int generate_LOCKCONST(cctx_T *cctx) { - isn_T *isn; - RETURN_OK_IF_SKIP(cctx); - if ((isn = generate_instr(cctx, ISN_LOCKCONST)) == NULL) + if (generate_instr(cctx, ISN_LOCKCONST) == NULL) return FAIL; return OK; } @@ -1678,6 +1669,22 @@ generate_PCALL( return OK; } +/* + * Generate an ISN_DEFER instruction. + */ + int +generate_DEFER(cctx_T *cctx, int var_idx, int argcount) +{ + isn_T *isn; + + RETURN_OK_IF_SKIP(cctx); + if ((isn = generate_instr_drop(cctx, ISN_DEFER, argcount + 1)) == NULL) + return FAIL; + isn->isn_arg.defer.defer_var_idx = var_idx; + isn->isn_arg.defer.defer_argcount = argcount; + return OK; +} + /* * Generate an ISN_STRINGMEMBER instruction. */ @@ -2240,6 +2247,7 @@ delete_instr(isn_T *isn) case ISN_CONCAT: case ISN_COND2BOOL: case ISN_DEBUG: + case ISN_DEFER: case ISN_DROP: case ISN_ECHO: case ISN_ECHOCONSOLE: @@ -2296,21 +2304,21 @@ delete_instr(isn_T *isn) case ISN_STOREINDEX: case ISN_STORENR: case ISN_SOURCE: - case ISN_STOREOUTER: - case ISN_STORERANGE: - case ISN_STOREREG: - case ISN_STOREV: - case ISN_STRINDEX: - case ISN_STRSLICE: - case ISN_THROW: - case ISN_TRYCONT: - case ISN_UNLETINDEX: - case ISN_UNLETRANGE: - case ISN_UNPACK: - case ISN_USEDICT: + case ISN_STOREOUTER: + case ISN_STORERANGE: + case ISN_STOREREG: + case ISN_STOREV: + case ISN_STRINDEX: + case ISN_STRSLICE: + case ISN_THROW: + case ISN_TRYCONT: + case ISN_UNLETINDEX: + case ISN_UNLETRANGE: + case ISN_UNPACK: + case ISN_USEDICT: // nothing allocated break; -} + } } void diff --git a/src/viminfo.c b/src/viminfo.c index acdf61825f..546103e978 100644 --- a/src/viminfo.c +++ b/src/viminfo.c @@ -2324,7 +2324,7 @@ copy_viminfo_marks( // Read the next line. If it has the "*" mark compare the // time stamps. Write entries from "buflist" that are // newer. - if (!(eof = viminfo_readline(virp)) && line[0] == TAB) + if (!viminfo_readline(virp) && line[0] == TAB) { did_read_line = TRUE; if (line[1] == '*') diff --git a/src/xxd/xxd.c b/src/xxd/xxd.c index 8429b98ec5..c9e4c46788 100644 --- a/src/xxd/xxd.c +++ b/src/xxd/xxd.c @@ -782,7 +782,6 @@ main(int argc, char *argv[]) } p = 0; - c = 0; while ((length < 0 || p < length) && (c = getc_or_die(fp)) != EOF) { FPRINTF_OR_DIE((fpo, (hexx == hexxa) ? "%s0x%02x" : "%s0X%02X",