aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/lua.txt11
-rw-r--r--runtime/doc/map.txt3
-rw-r--r--runtime/ftplugin/changelog.vim26
-rw-r--r--runtime/ftplugin/nsis.vim4
-rw-r--r--runtime/indent/dosbatch.vim4
-rw-r--r--runtime/indent/nsis.vim4
-rw-r--r--runtime/indent/teraterm.vim4
-rw-r--r--runtime/syntax/arduino.vim99
-rw-r--r--runtime/syntax/debchangelog.vim5
-rw-r--r--runtime/syntax/debsources.vim5
-rw-r--r--runtime/syntax/nsis.vim42
-rw-r--r--src/nvim/api/buffer.c38
-rw-r--r--src/nvim/buffer.c182
-rw-r--r--src/nvim/buffer_defs.h7
-rw-r--r--src/nvim/decoration.c90
-rw-r--r--src/nvim/decoration.h18
-rw-r--r--src/nvim/edit.c8
-rw-r--r--src/nvim/eval.c34
-rw-r--r--src/nvim/eval/userfunc.c32
-rw-r--r--src/nvim/ex_cmds.c140
-rw-r--r--src/nvim/ex_cmds.h3
-rw-r--r--src/nvim/ex_docmd.c87
-rw-r--r--src/nvim/ex_eval.c160
-rw-r--r--src/nvim/ex_getln.c20
-rw-r--r--src/nvim/extmark.c40
-rw-r--r--src/nvim/extmark_defs.h10
-rw-r--r--src/nvim/fileio.c100
-rw-r--r--src/nvim/fileio.h1
-rw-r--r--src/nvim/fold.c128
-rw-r--r--src/nvim/getchar.c43
-rw-r--r--src/nvim/hardcopy.c131
-rw-r--r--src/nvim/lib/kvec.h12
-rw-r--r--src/nvim/main.c10
-rw-r--r--src/nvim/marktree.c8
-rw-r--r--src/nvim/marktree.h9
-rw-r--r--src/nvim/mbyte.c28
-rw-r--r--src/nvim/memline.c24
-rw-r--r--src/nvim/menu.c28
-rw-r--r--src/nvim/message.c46
-rw-r--r--src/nvim/misc1.c79
-rw-r--r--src/nvim/move.c66
-rw-r--r--src/nvim/normal.c106
-rw-r--r--src/nvim/ops.c74
-rw-r--r--src/nvim/option.c54
-rw-r--r--src/nvim/plines.c4
-rw-r--r--src/nvim/quickfix.c4
-rw-r--r--src/nvim/regexp.c52
-rw-r--r--src/nvim/regexp_nfa.c191
-rw-r--r--src/nvim/screen.c42
-rw-r--r--src/nvim/search.c107
-rw-r--r--src/nvim/syntax.c68
-rw-r--r--src/nvim/tag.c70
-rw-r--r--src/nvim/testdir/test_quickfix.vim17
-rw-r--r--src/nvim/undo.c68
-rw-r--r--src/nvim/window.c88
-rw-r--r--test/functional/lua/luaeval_spec.lua6
-rw-r--r--test/functional/ui/decorations_spec.lua7
-rw-r--r--test/unit/marktree_spec.lua4
58 files changed, 1415 insertions, 1336 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index fe94e89e2a..877c838602 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -393,6 +393,14 @@ where the args are converted to Lua values. The expression >
is equivalent to the Lua chunk >
return somemod.func(...)
+In addition, functions of packages can be accessed like >
+ v:lua.require'mypack'.func(arg1, arg2)
+ v:lua.require'mypack.submod'.func(arg1, arg2)
+Note: only single quote form without parens is allowed. Using
+`require"mypack"` or `require('mypack')` as prefixes do NOT work (the latter
+is still valid as a function call of itself, in case require returns a useful
+value).
+
The `v:lua` prefix may be used to call Lua functions as |method|s. For
example: >
arg1->v:lua.somemod.func(arg2)
@@ -409,7 +417,8 @@ For example consider the following Lua omnifunc handler: >
end
vim.api.nvim_buf_set_option(0, 'omnifunc', 'v:lua.mymod.omnifunc')
-Note: the module ("mymod" in the above example) must be a Lua global.
+Note: the module ("mymod" in the above example) must either be a Lua global,
+or use the require syntax as specified above to access it from a package.
Note: `v:lua` without a call is not allowed in a Vimscript expression:
|Funcref|s cannot represent Lua functions. The following are errors: >
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 64c0d96aed..90d4c4de93 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -877,6 +877,9 @@ Also note that the 'clipboard' option is temporarily emptied to avoid
clobbering the `"*` or `"+` registers, if its value contains the item `unnamed`
or `unnamedplus`.
+The `mode()` function will return the state as it will be after applying the
+operator.
+
==============================================================================
2. Abbreviations *abbreviations* *Abbreviations*
diff --git a/runtime/ftplugin/changelog.vim b/runtime/ftplugin/changelog.vim
index 257e9cd9d4..e9df63f8c9 100644
--- a/runtime/ftplugin/changelog.vim
+++ b/runtime/ftplugin/changelog.vim
@@ -2,7 +2,7 @@
" Language: generic Changelog file
" Maintainer: Martin Florian <marfl@posteo.de>
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2015-10-25
+" Latest Revision: 2021-10-17
" Variables:
" g:changelog_timeformat (deprecated: use g:changelog_dateformat instead) -
" description: the timeformat used in ChangeLog entries.
@@ -55,7 +55,7 @@ if &filetype == 'changelog'
elseif $EMAIL_ADDRESS != ""
return $EMAIL_ADDRESS
endif
-
+
let login = s:login()
return printf('%s <%s@%s>', s:name(login), login, s:hostname())
endfunction
@@ -223,12 +223,6 @@ if &filetype == 'changelog'
let &paste = save_paste
endfunction
- if exists(":NewChangelogEntry") != 2
- nnoremap <buffer> <silent> <Leader>o :<C-u>call <SID>new_changelog_entry('')<CR>
- xnoremap <buffer> <silent> <Leader>o :<C-u>call <SID>new_changelog_entry('')<CR>
- command! -nargs=0 NewChangelogEntry call s:new_changelog_entry('')
- endif
-
let b:undo_ftplugin = "setl com< fo< et< ai<"
setlocal comments=
@@ -241,14 +235,26 @@ if &filetype == 'changelog'
let b:undo_ftplugin .= " tw<"
endif
+ if !exists("no_plugin_maps") && !exists("no_changelog_maps") && exists(":NewChangelogEntry") != 2
+ nnoremap <buffer> <silent> <Leader>o :<C-u>call <SID>new_changelog_entry('')<CR>
+ xnoremap <buffer> <silent> <Leader>o :<C-u>call <SID>new_changelog_entry('')<CR>
+ command! -buffer -nargs=0 NewChangelogEntry call s:new_changelog_entry('')
+ let b:undo_ftplugin .= " | sil! exe 'nunmap <buffer> <Leader>o'" .
+ \ " | sil! exe 'vunmap <buffer> <Leader>o'" .
+ \ " | sil! delc NewChangelogEntry"
+ endif
+
let &cpo = s:cpo_save
unlet s:cpo_save
else
let s:cpo_save = &cpo
set cpo&vim
- " Add the Changelog opening mapping
- nnoremap <silent> <Leader>o :call <SID>open_changelog()<CR>
+ if !exists("no_plugin_maps") && !exists("no_changelog_maps")
+ " Add the Changelog opening mapping
+ nnoremap <silent> <Leader>o :call <SID>open_changelog()<CR>
+ let b:undo_ftplugin .= " | silent! exe 'nunmap <buffer> <Leader>o"
+ endif
function! s:open_changelog()
let path = expand('%:p:h')
diff --git a/runtime/ftplugin/nsis.vim b/runtime/ftplugin/nsis.vim
index 1a35127c86..3dc0d6318a 100644
--- a/runtime/ftplugin/nsis.vim
+++ b/runtime/ftplugin/nsis.vim
@@ -3,7 +3,7 @@
" Maintainer: Ken Takata
" URL: https://github.com/k-takata/vim-nsis
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
-" Last Change: 2018-01-26
+" Last Change: 2021-10-18
if exists("b:did_ftplugin")
finish
@@ -15,7 +15,6 @@ set cpo&vim
let b:did_ftplugin = 1
let b:undo_ftplugin = "setl com< cms< fo< def< inc<"
- \ " | unlet! b:match_ignorecase b:match_words"
setlocal comments=s1:/*,mb:*,ex:*/,b:#,:; commentstring=;\ %s
setlocal formatoptions-=t formatoptions+=croql
@@ -37,6 +36,7 @@ if exists("loaded_matchit")
\ '\${MementoSection}:\${MementoSectionEnd},' .
\ '!if\%(\%(macro\)\?n\?def\)\?\>:!else\>:!endif\>,' .
\ '!macro\>:!macroend\>'
+ let b:undo_ftplugin .= " | unlet! b:match_ignorecase b:match_words"
endif
let &cpo = s:cpo_save
diff --git a/runtime/indent/dosbatch.vim b/runtime/indent/dosbatch.vim
index aea2a184d4..d24b139242 100644
--- a/runtime/indent/dosbatch.vim
+++ b/runtime/indent/dosbatch.vim
@@ -2,7 +2,7 @@
" Language: MSDOS batch file (with NT command extensions)
" Maintainer: Ken Takata
" URL: https://github.com/k-takata/vim-dosbatch-indent
-" Last Change: 2017 May 10
+" Last Change: 2021-10-18
" Filenames: *.bat
" License: VIM License
@@ -17,6 +17,8 @@ setlocal indentexpr=GetDosBatchIndent(v:lnum)
setlocal indentkeys=!^F,o,O
setlocal indentkeys+=0=)
+let b:undo_indent = "setl ai< inde< indk< si<"
+
if exists("*GetDosBatchIndent")
finish
endif
diff --git a/runtime/indent/nsis.vim b/runtime/indent/nsis.vim
index 223f4fa28e..5d3decca37 100644
--- a/runtime/indent/nsis.vim
+++ b/runtime/indent/nsis.vim
@@ -2,7 +2,7 @@
" Language: NSIS script
" Maintainer: Ken Takata
" URL: https://github.com/k-takata/vim-nsis
-" Last Change: 2018-01-21
+" Last Change: 2021-10-18
" Filenames: *.nsi
" License: VIM License
@@ -17,6 +17,8 @@ setlocal indentexpr=GetNsisIndent(v:lnum)
setlocal indentkeys=!^F,o,O
setlocal indentkeys+==~${Else,=~${EndIf,=~${EndUnless,=~${AndIf,=~${AndUnless,=~${OrIf,=~${OrUnless,=~${Case,=~${Default,=~${EndSelect,=~${EndSwith,=~${Loop,=~${Next,=~${MementoSectionEnd,=~FunctionEnd,=~SectionEnd,=~SectionGroupEnd,=~PageExEnd,0=~!macroend,0=~!if,0=~!else,0=~!endif
+let b:undo_indent = "setl ai< inde< indk< si<"
+
if exists("*GetNsisIndent")
finish
endif
diff --git a/runtime/indent/teraterm.vim b/runtime/indent/teraterm.vim
index 35d7354290..181c9a343f 100644
--- a/runtime/indent/teraterm.vim
+++ b/runtime/indent/teraterm.vim
@@ -3,7 +3,7 @@
" Based on Tera Term Version 4.100
" Maintainer: Ken Takata
" URL: https://github.com/k-takata/vim-teraterm
-" Last Change: 2018-08-31
+" Last Change: 2021-10-18
" Filenames: *.ttl
" License: VIM License
@@ -18,6 +18,8 @@ setlocal indentexpr=GetTeraTermIndent(v:lnum)
setlocal indentkeys=!^F,o,O,e
setlocal indentkeys+==elseif,=endif,=loop,=next,=enduntil,=endwhile
+let b:undo_indent = "setl ai< inde< indk< si<"
+
if exists("*GetTeraTermIndent")
finish
endif
diff --git a/runtime/syntax/arduino.vim b/runtime/syntax/arduino.vim
index 4a4ef82072..1c9618ff0f 100644
--- a/runtime/syntax/arduino.vim
+++ b/runtime/syntax/arduino.vim
@@ -1,50 +1,79 @@
" Vim syntax file
" Language: Arduino
" Maintainer: Johannes Hoff <johannes@johanneshoff.com>
-" Last Change: 2011 June 3
+" Last Change: 21 October 2021
" License: VIM license (:help license, replace vim by arduino.vim)
" Syntax highlighting like in the Arduino IDE
-" Keywords extracted from <arduino>/build/shared/lib/keywords.txt (arduino
-" version 0021)
+" Automatically generated by the script available at
+" https://bitbucket.org/johannes/arduino-vim-syntax
+" Using keywords from <arduino>/build/shared/lib/keywords.txt
+" From version: 1.8.16
-" Thanks to Rik, Erik Nomitch, Adam Obeng and Graeme Cross for helpful feedback!
+" Thanks to Rik, Erik Nomitch, Adam Obeng, Graeme Cross and Niall Parker
+" for helpful feedback!
-" quit when a syntax file was already loaded
-if exists("b:current_syntax")
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+ syntax clear
+elseif exists("b:current_syntax")
finish
endif
" Read the C syntax to start with
-runtime! syntax/cpp.vim
-
-syn keyword arduinoConstant HIGH LOW INPUT OUTPUT
-syn keyword arduinoConstant DEC BIN HEX OCT BYTE
-syn keyword arduinoConstant PI HALF_PI TWO_PI
-syn keyword arduinoConstant LSBFIRST MSBFIRST
-syn keyword arduinoConstant CHANGE FALLING RISING
-syn keyword arduinoConstant SERIAL DISPLAY
-syn keyword arduinoConstant DEFAULT EXTERNAL INTERNAL INTERNAL1V1 INTERNAL2V56
-
-syn keyword arduinoStdFunc abs acos asin atan atan2 ceil constrain
-syn keyword arduinoStdFunc cos degrees exp floor log
-syn keyword arduinoStdFunc map max min pow radians
-syn keyword arduinoStdFunc round sin sq sqrt tan
-syn keyword arduinoStdFunc randomSeed random
-
-syn keyword arduinoFunc analogReference analogRead analogWrite
-syn keyword arduinoFunc attachInterrupt detachInterrupt interrupts noInterrupts
-syn keyword arduinoFunc lowByte highByte bitRead bitWrite bitSet bitClear
-syn keyword arduinoFunc millis micros delay delayMicroseconds
-syn keyword arduinoFunc pinMode digitalWrite digitalRead
-syn keyword arduinoFunc tone noTone pulseIn shiftOut
-
-syn keyword arduinoMethod setup loop
-syn keyword arduinoMethod begin end available read flush print println write peek
-
-syn keyword arduinoType boolean byte word String
-
-syn keyword arduinoModule Serial Serial1 Serial2 Serial3
+if version < 600
+ so <sfile>:p:h/cpp.vim
+else
+ runtime! syntax/cpp.vim
+endif
+
+syn keyword arduinoConstant BIN CHANGE DEC DEFAULT EXTERNAL FALLING HALF_PI HEX
+syn keyword arduinoConstant HIGH INPUT INPUT_PULLUP INTERNAL INTERNAL1V1
+syn keyword arduinoConstant INTERNAL2V56 LED_BUILTIN LED_BUILTIN_RX
+syn keyword arduinoConstant LED_BUILTIN_TX LOW LSBFIRST MSBFIRST OCT OUTPUT PI
+syn keyword arduinoConstant RISING TWO_PI
+
+syn keyword arduinoFunc analogRead analogReadResolution analogReference
+syn keyword arduinoFunc analogWrite analogWriteResolution attachInterrupt
+syn keyword arduinoFunc bit bitClear bitRead bitSet bitWrite delay
+syn keyword arduinoFunc delayMicroseconds detachInterrupt
+syn keyword arduinoFunc digitalPinToInterrupt digitalRead digitalWrite
+syn keyword arduinoFunc highByte interrupts lowByte micros millis
+syn keyword arduinoFunc noInterrupts noTone pinMode pulseIn pulseInLong
+syn keyword arduinoFunc shiftIn shiftOut tone yield
+
+syn keyword arduinoMethod available availableForWrite begin charAt compareTo
+syn keyword arduinoMethod concat end endsWith equals equalsIgnoreCase export
+syn keyword arduinoMethod final find findUntil flush getBytes indexOf
+syn keyword arduinoMethod lastIndexOf length loop override parseFloat
+syn keyword arduinoMethod parseInt peek print println read readBytes
+syn keyword arduinoMethod readBytesUntil readString readStringUntil replace
+syn keyword arduinoMethod setCharAt setTimeout setup startsWith Stream
+syn keyword arduinoMethod substring toCharArray toInt toLowerCase toUpperCase
+syn keyword arduinoMethod trim
+
+syn keyword arduinoModule Keyboard Mouse Serial Serial1 Serial2 Serial3
+syn keyword arduinoModule SerialUSB
+
+syn keyword arduinoStdFunc abs accept acos acosf asin asinf atan atan2 atan2f
+syn keyword arduinoStdFunc atanf cbrt cbrtf ceil ceilf click constrain
+syn keyword arduinoStdFunc copysign copysignf cos cosf cosh coshf degrees exp
+syn keyword arduinoStdFunc expf fabs fabsf fdim fdimf floor floorf fma fmaf
+syn keyword arduinoStdFunc fmax fmaxf fmin fminf fmod fmodf hypot hypotf
+syn keyword arduinoStdFunc isfinite isinf isnan isPressed ldexp ldexpf log
+syn keyword arduinoStdFunc log10 log10f logf lrint lrintf lround lroundf map
+syn keyword arduinoStdFunc max min move pow powf press radians random
+syn keyword arduinoStdFunc randomSeed release releaseAll round roundf signbit
+syn keyword arduinoStdFunc sin sinf sinh sinhf sq sqrt sqrtf tan tanf tanh
+syn keyword arduinoStdFunc tanhf trunc truncf
+
+syn keyword arduinoType _Bool _Complex _Imaginary array atomic_bool
+syn keyword arduinoType atomic_char atomic_int atomic_llong atomic_long
+syn keyword arduinoType atomic_schar atomic_short atomic_uchar atomic_uint
+syn keyword arduinoType atomic_ullong atomic_ulong atomic_ushort boolean
+syn keyword arduinoType byte char16_t char32_t complex NULL null PROGMEM
+syn keyword arduinoType String word
hi def link arduinoType Type
hi def link arduinoConstant Constant
diff --git a/runtime/syntax/debchangelog.vim b/runtime/syntax/debchangelog.vim
index 93b03ae06d..79352c0827 100644
--- a/runtime/syntax/debchangelog.vim
+++ b/runtime/syntax/debchangelog.vim
@@ -3,7 +3,7 @@
" Maintainer: Debian Vim Maintainers
" Former Maintainers: Gerfried Fuchs <alfie@ist.org>
" Wichert Akkerman <wakkerma@debian.org>
-" Last Change: 2021 Aug 03
+" Last Change: 2021 Oct 19
" URL: https://salsa.debian.org/vim-team/vim-debian/blob/master/syntax/debchangelog.vim
" Standard syntax initialization
@@ -24,7 +24,8 @@ let s:supported = [
\ 'jessie', 'stretch', 'buster', 'bullseye', 'bookworm',
\ 'trixie', 'sid', 'rc-buggy',
\
- \ 'trusty', 'xenial', 'bionic', 'focal', 'hirsute', 'impish', 'devel'
+ \ 'trusty', 'xenial', 'bionic', 'focal', 'hirsute', 'impish', 'jammy',
+ \ 'devel'
\ ]
let s:unsupported = [
\ 'frozen', 'buzz', 'rex', 'bo', 'hamm', 'slink', 'potato',
diff --git a/runtime/syntax/debsources.vim b/runtime/syntax/debsources.vim
index 8aa96fcb58..4b4c497f18 100644
--- a/runtime/syntax/debsources.vim
+++ b/runtime/syntax/debsources.vim
@@ -2,7 +2,7 @@
" Language: Debian sources.list
" Maintainer: Debian Vim Maintainers
" Former Maintainer: Matthijs Mohlmann <matthijs@cacholong.nl>
-" Last Change: 2021 Aug 03
+" Last Change: 2021 Oct 19
" URL: https://salsa.debian.org/vim-team/vim-debian/blob/master/syntax/debsources.vim
" Standard syntax initialization
@@ -26,7 +26,8 @@ let s:supported = [
\ 'jessie', 'stretch', 'buster', 'bullseye', 'bookworm',
\ 'trixie', 'sid', 'rc-buggy',
\
- \ 'trusty', 'xenial', 'bionic', 'focal', 'hirsute', 'impish', 'devel'
+ \ 'trusty', 'xenial', 'bionic', 'focal', 'hirsute', 'impish', 'jammy',
+ \ 'devel'
\ ]
let s:unsupported = [
\ 'buzz', 'rex', 'bo', 'hamm', 'slink', 'potato',
diff --git a/runtime/syntax/nsis.vim b/runtime/syntax/nsis.vim
index 3389771b78..3a73fe0989 100644
--- a/runtime/syntax/nsis.vim
+++ b/runtime/syntax/nsis.vim
@@ -1,9 +1,9 @@
" Vim syntax file
-" Language: NSIS script, for version of NSIS 3.03 and later
+" Language: NSIS script, for version of NSIS 3.08 and later
" Maintainer: Ken Takata
" URL: https://github.com/k-takata/vim-nsis
" Previous Maintainer: Alex Jakushev <Alex.Jakushev@kemek.lt>
-" Last Change: 2018-10-02
+" Last Change: 2020-10-18
" quit when a syntax file was already loaded
if exists("b:current_syntax")
@@ -97,6 +97,8 @@ syn match nsisSysVar "$RESOURCES_LOCALIZED"
syn match nsisSysVar "$CDBURN_AREA"
syn match nsisSysVar "$HWNDPARENT"
syn match nsisSysVar "$PLUGINSDIR"
+syn match nsisSysVar "$\%(USERTEMPLATES\|USERSTARTMENU\|USERSMPROGRAMS\|USERDESKTOP\)"
+syn match nsisSysVar "$\%(COMMONTEMPLATES\|COMMONSTARTMENU\|COMMONSMPROGRAMS\|COMMONDESKTOP\|COMMONPROGRAMDATA\)"
syn match nsisSysVar "$\\r"
syn match nsisSysVar "$\\n"
syn match nsisSysVar "$\\t"
@@ -149,7 +151,7 @@ syn keyword nsisStatement contained Section nextgroup=nsisSectionOpt skipwhite
syn region nsisSectionOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisSectionKwd
syn match nsisSectionKwd contained "/o\>"
-syn keyword nsisStatement contained SectionIn nextgroup=nsisSectionInOpt skipwhite
+syn keyword nsisStatement contained SectionInstType SectionIn nextgroup=nsisSectionInOpt skipwhite
syn region nsisSectionInOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisSectionInKwd
syn keyword nsisSectionInKwd contained RO
@@ -269,10 +271,22 @@ syn keyword nsisAttribute contained ManifestDPIAware nextgroup=nsisManifestDPIAw
syn region nsisManifestDPIAwareOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisManifestDPIAwareKwd
syn keyword nsisManifestDPIAwareKwd contained notset true false
+syn keyword nsisAttribute contained ManifestLongPathAware nextgroup=nsisManifestLongPathAwareOpt skipwhite
+syn region nsisManifestLongPathAwareOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisManifestLongPathAwareKwd
+syn match nsisManifestLongPathAwareKwd contained "\<\%(notset\|true\|false\)\>"
+
syn keyword nsisAttribute contained ManifestSupportedOS nextgroup=nsisManifestSupportedOSOpt skipwhite
syn region nsisManifestSupportedOSOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisManifestSupportedOSKwd
syn match nsisManifestSupportedOSKwd contained "\<\%(none\|all\|WinVista\|Win7\|Win8\|Win8\.1\|Win10\)\>"
+syn keyword nsisAttribute contained PEAddResource nextgroup=nsisPEAddResourceOpt skipwhite
+syn region nsisPEAddResourceOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisPEAddResourceKwd
+syn match nsisPEAddResourceKwd contained "/\%(OVERWRITE\|REPLACE\)\>"
+
+syn keyword nsisAttribute contained PERemoveResource nextgroup=nsisPERemoveResourceOpt skipwhite
+syn region nsisPERemoveResourceOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisPERemoveResourceKwd
+syn match nsisPERemoveResourceKwd contained "/NOERRORS\>"
+
syn keyword nsisAttribute contained RequestExecutionLevel nextgroup=nsisRequestExecutionLevelOpt skipwhite
syn region nsisRequestExecutionLevelOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisRequestExecutionLevelKwd
syn keyword nsisRequestExecutionLevelKwd contained none user highest admin
@@ -353,7 +367,7 @@ syn keyword nsisInstruction contained ExpandEnvStrings ReadEnvStr
syn keyword nsisInstruction contained DeleteRegKey nextgroup=nsisDeleteRegKeyOpt skipwhite
syn region nsisDeleteRegKeyOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisDeleteRegKeyKwd,nsisRegistry
-syn match nsisDeleteRegKeyKwd contained "/ifempty\>"
+syn match nsisDeleteRegKeyKwd contained "/\%(ifempty\|ifnosubkeys\|ifnovalues\)\>"
syn keyword nsisInstruction contained nextgroup=nsisRegistryOpt skipwhite
\ DeleteRegValue EnumRegKey EnumRegValue ReadRegDWORD ReadRegStr WriteRegBin WriteRegDWORD WriteRegExpandStr WriteRegStr
@@ -368,8 +382,8 @@ syn region nsisSetRegViewOpt contained start="" end="$" transparent keepend cont
syn keyword nsisSetRegViewKwd contained default lastused
"FUNCTIONS - general purpose (4.9.3)
-syn keyword nsisInstruction contained CallInstDLL CreateDirectory GetDLLVersion
-syn keyword nsisInstruction contained GetDLLVersionLocal GetFileTime GetFileTimeLocal
+syn keyword nsisInstruction contained CallInstDLL CreateDirectory GetWinVer
+syn keyword nsisInstruction contained GetFileTime GetFileTimeLocal GetKnownFolderPath
syn keyword nsisInstruction contained GetTempFileName SearchPath RegDLL UnRegDLL
syn keyword nsisInstruction contained CopyFiles nextgroup=nsisCopyFilesOpt skipwhite
@@ -380,6 +394,10 @@ syn keyword nsisInstruction contained CreateShortcut nextgroup=nsisCreateShortcu
syn region nsisCreateShortcutOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisCreateShortcutKwd
syn match nsisCreateShortcutKwd contained "/NoWorkingDir\>"
+syn keyword nsisInstruction contained GetDLLVersion GetDLLVersionLocal nextgroup=nsisGetDLLVersionOpt skipwhite
+syn region nsisGetDLLVersionOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisGetDLLVersionKwd
+syn match nsisGetDLLVersionKwd contained "/ProductVersion\>"
+
syn keyword nsisInstruction contained GetFullPathName nextgroup=nsisGetFullPathNameOpt skipwhite
syn region nsisGetFullPathNameOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisGetFullPathNameKwd
syn match nsisGetFullPathNameKwd contained "/SHORT\>"
@@ -395,6 +413,7 @@ syn keyword nsisFileAttrib contained FILE_ATTRIBUTE_TEMPORARY
syn keyword nsisInstruction contained Abort Call ClearErrors GetCurrentAddress
syn keyword nsisInstruction contained GetFunctionAddress GetLabelAddress Goto
syn keyword nsisInstruction contained IfAbort IfErrors IfFileExists IfRebootFlag IfSilent
+syn keyword nsisInstruction contained IfShellVarContextAll IfRtlLanguage
syn keyword nsisInstruction contained IntCmp IntCmpU Int64Cmp Int64CmpU IntPtrCmp IntPtrCmpU
syn keyword nsisInstruction contained Return Quit SetErrors StrCmp StrCmpS
@@ -460,6 +479,10 @@ syn keyword nsisInstruction contained CreateFont nextgroup=nsisFontOpt skipwhite
syn keyword nsisInstruction contained nextgroup=nsisBooleanOpt skipwhite
\ LockWindow SetAutoClose
+syn keyword nsisInstruction contained LoadAndSetImage nextgroup=nsisLoadAndSetImageOpt skipwhite
+syn region nsisLoadAndSetImageOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisLoadAndSetImageKwd
+syn match nsisLoadAndSetImageKwd contained "/\%(EXERESOURCE\|STRINGID\|RESIZETOFIT\%(WIDTH\|HEIGHT\)\)\>"
+
syn keyword nsisInstruction contained SendMessage nextgroup=nsisSendMessageOpt skipwhite
syn region nsisSendMessageOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisSendMessageKwd
syn match nsisSendMessageKwd contained "/TIMEOUT\>"
@@ -556,7 +579,7 @@ syn keyword nsisVerboseKwd contained push pop
"PREPROCESSOR (5.4)
syn match nsisDefine contained "!define\>" nextgroup=nsisDefineOpt skipwhite
syn region nsisDefineOpt contained start="" end="$" transparent keepend contains=@nsisAnyOpt,nsisDefineKwd
-syn match nsisDefineKwd contained "/\%(ifndef\|redef\|date\|utcdate\|math\|file\)\>"
+syn match nsisDefineKwd contained "/\%(ifndef\|redef\|date\|utcdate\|file\|intfmt\|math\)\>"
syn match nsisDefine contained "!undef\>"
syn match nsisPreCondit contained "!ifdef\>"
@@ -615,7 +638,10 @@ hi def link nsisInstTypeKwd Constant
hi def link nsisLicenseBkColorKwd Constant
hi def link nsisLicenseForceSelectionKwd Constant
hi def link nsisManifestDPIAwareKwd Constant
+hi def link nsisManifestLongPathAwareKwd Constant
hi def link nsisManifestSupportedOSKwd Constant
+hi def link nsisPEAddResourceKwd Constant
+hi def link nsisPERemoveResourceKwd Constant
hi def link nsisRequestExecutionLevelKwd Constant
hi def link nsisShowInstDetailsKwd Constant
hi def link nsisSilentInstallKwd Constant
@@ -633,11 +659,13 @@ hi def link nsisWriteRegMultiStrKwd Constant
hi def link nsisSetRegViewKwd Constant
hi def link nsisCopyFilesKwd Constant
hi def link nsisCreateShortcutKwd Constant
+hi def link nsisGetDLLVersionKwd Constant
hi def link nsisGetFullPathNameKwd Constant
hi def link nsisFileAttrib Constant
hi def link nsisMessageBox Constant
hi def link nsisFileWriteUTF16LEKwd Constant
hi def link nsisSetShellVarContextKwd Constant
+hi def link nsisLoadAndSetImageKwd Constant
hi def link nsisSendMessageKwd Constant
hi def link nsisSetBrandingImageKwd Constant
hi def link nsisSetDetailsViewKwd Constant
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 31d44c68bf..92fcb59b34 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -247,7 +247,6 @@ Boolean nvim_buf_detach(uint64_t channel_id, Buffer buffer, Error *err)
}
void nvim__buf_redraw_range(Buffer buffer, Integer first, Integer last, Error *err)
- FUNC_API_LUA_ONLY
{
buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) {
@@ -1531,12 +1530,6 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e
/// option is still used for hard tabs. By default lines are
/// placed below the buffer line containing the mark.
///
-/// Note: currently virtual lines are limited to one block
-/// per buffer. Thus setting a new mark disables any previous
-/// `virt_lines` decoration. However plugins should not rely
-/// on this behaviour, as this limitation is planned to be
-/// removed.
-///
/// - virt_lines_above: place virtual lines above instead.
/// - virt_lines_leftcol: Place extmarks in the leftmost
/// column of the window, bypassing
@@ -1680,9 +1673,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
goto error;
}
- VirtLines virt_lines = KV_INITIAL_VALUE;
- bool virt_lines_above = false;
bool virt_lines_leftcol = false;
+ OPTION_TO_BOOL(virt_lines_leftcol, virt_lines_leftcol, false);
if (opts->virt_lines.type == kObjectTypeArray) {
Array a = opts->virt_lines.data.array;
@@ -1693,7 +1685,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
}
int dummig;
VirtText jtem = parse_virt_text(a.items[j].data.array, err, &dummig);
- kv_push(virt_lines, jtem);
+ kv_push(decor.virt_lines, ((struct virt_line){ jtem, virt_lines_leftcol }));
if (ERROR_SET(err)) {
goto error;
}
@@ -1703,8 +1695,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
goto error;
}
- OPTION_TO_BOOL(virt_lines_above, virt_lines_above, false);
- OPTION_TO_BOOL(virt_lines_leftcol, virt_lines_leftcol, false);
+
+ OPTION_TO_BOOL(decor.virt_lines_above, virt_lines_above, false);
if (opts->priority.type == kObjectTypeInteger) {
Integer val = opts->priority.data.integer;
@@ -1774,7 +1766,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
if (ephemeral) {
d = &decor;
- } else if (kv_size(decor.virt_text)
+ } else if (kv_size(decor.virt_text) || kv_size(decor.virt_lines)
|| decor.priority != DECOR_PRIORITY_BASE
|| decor.hl_eol) {
// TODO(bfredl): this is a bit sketchy. eventually we should
@@ -1794,22 +1786,11 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
goto error;
}
- if (kv_size(virt_lines) && buf->b_virt_line_mark) {
- mtpos_t pos = marktree_lookup(buf->b_marktree, buf->b_virt_line_mark, NULL);
- clear_virt_lines(buf, pos.row); // handles pos.row == -1
- }
+ extmark_set(buf, (uint64_t)ns_id, &id, (int)line, (colnr_T)col, line2, col2,
+ d, right_gravity, end_right_gravity, kExtmarkNoUndo);
- uint64_t mark = extmark_set(buf, (uint64_t)ns_id, &id, (int)line, (colnr_T)col,
- line2, col2, d, right_gravity,
- end_right_gravity, kExtmarkNoUndo);
-
- if (kv_size(virt_lines)) {
- buf->b_virt_lines = virt_lines;
- buf->b_virt_line_mark = mark;
- buf->b_virt_line_pos = -1;
- buf->b_virt_line_above = virt_lines_above;
- buf->b_virt_line_leftcol = virt_lines_leftcol;
- redraw_buf_line_later(buf, MIN(buf->b_ml.ml_line_count, line+1+(virt_lines_above?0:1)));
+ if (kv_size(decor.virt_lines)) {
+ redraw_buf_line_later(buf, MIN(buf->b_ml.ml_line_count, line+1+(decor.virt_lines_above?0:1)));
}
}
@@ -2013,6 +1994,7 @@ Dictionary nvim__buf_stats(Buffer buffer, Error *err)
// this exists to debug issues
PUT(rv, "dirty_bytes", INTEGER_OBJ((Integer)buf->deleted_bytes));
PUT(rv, "dirty_bytes2", INTEGER_OBJ((Integer)buf->deleted_bytes2));
+ PUT(rv, "virt_blocks", INTEGER_OBJ((Integer)buf->b_virt_line_blocks));
u_header_T *uhp = NULL;
if (buf->b_u_curhead != NULL) {
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 826a197454..37a2060021 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -109,11 +109,9 @@ static int read_buffer(int read_stdin, exarg_T *eap, int flags)
int retval = OK;
linenr_T line_count;
- //
// Read from the buffer which the text is already filled in and append at
// the end. This makes it possible to retry when 'fileformat' or
// 'fileencoding' was guessed wrong.
- //
line_count = curbuf->b_ml.ml_line_count;
retval = readfile(read_stdin ? NULL : curbuf->b_ffname,
read_stdin ? NULL : curbuf->b_fname,
@@ -164,21 +162,17 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
long old_tw = curbuf->b_p_tw;
int read_fifo = false;
- /*
- * The 'readonly' flag is only set when BF_NEVERLOADED is being reset.
- * When re-entering the same buffer, it should not change, because the
- * user may have reset the flag by hand.
- */
+ // The 'readonly' flag is only set when BF_NEVERLOADED is being reset.
+ // When re-entering the same buffer, it should not change, because the
+ // user may have reset the flag by hand.
if (readonlymode && curbuf->b_ffname != NULL
&& (curbuf->b_flags & BF_NEVERLOADED)) {
curbuf->b_p_ro = true;
}
if (ml_open(curbuf) == FAIL) {
- /*
- * There MUST be a memfile, otherwise we can't do anything
- * If we can't create one for the current buffer, take another buffer
- */
+ // There MUST be a memfile, otherwise we can't do anything
+ // If we can't create one for the current buffer, take another buffer
close_buffer(NULL, curbuf, 0, false);
curbuf = NULL;
@@ -260,12 +254,10 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
} else if (read_stdin) {
int save_bin = curbuf->b_p_bin;
- /*
- * First read the text in binary mode into the buffer.
- * Then read from that same buffer and append at the end. This makes
- * it possible to retry when 'fileformat' or 'fileencoding' was
- * guessed wrong.
- */
+ // First read the text in binary mode into the buffer.
+ // Then read from that same buffer and append at the end. This makes
+ // it possible to retry when 'fileformat' or 'fileencoding' was
+ // guessed wrong.
curbuf->b_p_bin = true;
retval = readfile(NULL, NULL, (linenr_T)0,
(linenr_T)0, (linenr_T)MAXLNUM, NULL,
@@ -308,8 +300,8 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
curbuf->b_flags |= BF_READERR;
}
- /* Need to update automatic folding. Do this before the autocommands,
- * they may use the fold info. */
+ // Need to update automatic folding. Do this before the autocommands,
+ // they may use the fold info.
foldUpdateAll(curwin);
// need to set w_topline, unless some autocommand already did that.
@@ -323,10 +315,8 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
return FAIL;
}
- /*
- * The autocommands may have changed the current buffer. Apply the
- * modelines to the correct buffer, if it still exists and is loaded.
- */
+ // The autocommands may have changed the current buffer. Apply the
+ // modelines to the correct buffer, if it still exists and is loaded.
if (bufref_valid(&old_curbuf) && old_curbuf.br_buf->b_ml.ml_mfp != NULL) {
aco_save_T aco;
@@ -335,8 +325,10 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
do_modelines(0);
curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED);
- apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, false, curbuf,
- &retval);
+ if ((flags & READ_NOWINENTER) == 0) {
+ apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, false, curbuf,
+ &retval);
+ }
// restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
@@ -570,13 +562,11 @@ bool close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last)
return false;
}
- /*
- * It's possible that autocommands change curbuf to the one being deleted.
- * This might cause the previous curbuf to be deleted unexpectedly. But
- * in some cases it's OK to delete the curbuf, because a new one is
- * obtained anyway. Therefore only return if curbuf changed to the
- * deleted buffer.
- */
+ // It's possible that autocommands change curbuf to the one being deleted.
+ // This might cause the previous curbuf to be deleted unexpectedly. But
+ // in some cases it's OK to delete the curbuf, because a new one is
+ // obtained anyway. Therefore only return if curbuf changed to the
+ // deleted buffer.
if (buf == curbuf && !is_curbuf) {
return false;
}
@@ -717,12 +707,10 @@ void buf_freeall(buf_T *buf, int flags)
return;
}
- /*
- * It's possible that autocommands change curbuf to the one being deleted.
- * This might cause curbuf to be deleted unexpectedly. But in some cases
- * it's OK to delete the curbuf, because a new one is obtained anyway.
- * Therefore only return if curbuf changed to the deleted buffer.
- */
+ // It's possible that autocommands change curbuf to the one being deleted.
+ // This might cause curbuf to be deleted unexpectedly. But in some cases
+ // it's OK to delete the curbuf, because a new one is obtained anyway.
+ // Therefore only return if curbuf changed to the deleted buffer.
if (buf == curbuf && !is_curbuf) {
return;
}
@@ -818,7 +806,6 @@ static void free_buffer_stuff(buf_T *buf, int free_flags)
uc_clear(&buf->b_ucmds); // clear local user commands
buf_delete_signs(buf, (char_u *)"*"); // delete any signs
extmark_free_all(buf); // delete any extmarks
- clear_virt_lines(buf, -1);
map_clear_int(buf, MAP_ALL_MODES, true, false); // clear local mappings
map_clear_int(buf, MAP_ALL_MODES, true, true); // clear local abbrevs
XFREE_CLEAR(buf->b_start_fenc);
@@ -864,8 +851,8 @@ void goto_buffer(exarg_T *eap, int start, int dir, int count)
swap_exists_action = SEA_NONE;
swap_exists_did_quit = true;
- /* Restore the error/interrupt/exception state if not discarded by a
- * new aborting error, interrupt, or uncaught exception. */
+ // Restore the error/interrupt/exception state if not discarded by a
+ // new aborting error, interrupt, or uncaught exception.
leave_cleanup(&cs);
} else {
handle_swap_exists(&old_curbuf);
@@ -920,8 +907,8 @@ void handle_swap_exists(bufref_T *old_curbuf)
}
// If "old_curbuf" is NULL we are in big trouble here...
- /* Restore the error/interrupt/exception state if not discarded by a
- * new aborting error, interrupt, or uncaught exception. */
+ // Restore the error/interrupt/exception state if not discarded by a
+ // new aborting error, interrupt, or uncaught exception.
leave_cleanup(&cs);
} else if (swap_exists_action == SEA_RECOVER) {
// Reset the error/interrupt/exception state here so that
@@ -935,8 +922,8 @@ void handle_swap_exists(bufref_T *old_curbuf)
cmdline_row = msg_row;
do_modelines(0);
- /* Restore the error/interrupt/exception state if not discarded by a
- * new aborting error, interrupt, or uncaught exception. */
+ // Restore the error/interrupt/exception state if not discarded by a
+ // new aborting error, interrupt, or uncaught exception.
leave_cleanup(&cs);
}
swap_exists_action = SEA_NONE; // -V519
@@ -978,12 +965,10 @@ char_u *do_bufdel(int command, char_u *arg, int addr_count, int start_bnr, int e
}
for (; !got_int; os_breakcheck()) {
- /*
- * delete the current buffer last, otherwise when the
- * current buffer is deleted, the next buffer becomes
- * the current one and will be loaded, which may then
- * also be deleted, etc.
- */
+ // delete the current buffer last, otherwise when the
+ // current buffer is deleted, the next buffer becomes
+ // the current one and will be loaded, which may then
+ // also be deleted, etc.
if (bnr == curbuf->b_fnum) {
do_current = bnr;
} else if (do_buffer(command, DOBUF_FIRST, FORWARD, bnr,
@@ -991,9 +976,7 @@ char_u *do_bufdel(int command, char_u *arg, int addr_count, int start_bnr, int e
deleted++;
}
- /*
- * find next buffer number to delete/unload
- */
+ // find next buffer number to delete/unload
if (addr_count == 2) {
if (++bnr > end_bnr) {
break;
@@ -1153,8 +1136,8 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
} else {
bp = NULL;
while (count > 0 || (!unload && !buf->b_p_bl && bp != buf)) {
- /* remember the buffer where we start, we come back there when all
- * buffers are unlisted. */
+ // remember the buffer where we start, we come back there when all
+ // buffers are unlisted.
if (bp == NULL) {
bp = buf;
}
@@ -1197,16 +1180,14 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
}
- /*
- * delete buffer buf from memory and/or the list
- */
+ // delete buffer "buf" from memory and/or the list
if (unload) {
int forward;
bufref_T bufref;
set_bufref(&bufref, buf);
- /* When unloading or deleting a buffer that's already unloaded and
- * unlisted: fail silently. */
+ // When unloading or deleting a buffer that's already unloaded and
+ // unlisted: fail silently.
if (action != DOBUF_WIPE && buf->b_ml.ml_mfp == NULL && !buf->b_p_bl) {
return FAIL;
}
@@ -1248,10 +1229,8 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
end_visual_mode();
}
- /*
- * If deleting the last (listed) buffer, make it empty.
- * The last (listed) buffer cannot be unloaded.
- */
+ // If deleting the last (listed) buffer, make it empty.
+ // The last (listed) buffer cannot be unloaded.
bp = NULL;
FOR_ALL_BUFFERS(bp2) {
if (bp2->b_p_bl && bp2 != buf) {
@@ -1263,11 +1242,9 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
return empty_curbuf(true, forceit, action);
}
- /*
- * If the deleted buffer is the current one, close the current window
- * (unless it's the only window). Repeat this so long as we end up in
- * a window with this buffer.
- */
+ // If the deleted buffer is the current one, close the current window
+ // (unless it's the only window). Repeat this so long as we end up in
+ // a window with this buffer.
while (buf == curbuf
&& !(curwin->w_closing || curwin->w_buffer->b_locked > 0)
&& (!ONE_WINDOW || first_tabpage->tp_next != NULL)) {
@@ -1276,9 +1253,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
}
}
- /*
- * If the buffer to be deleted is not the current one, delete it here.
- */
+ // If the buffer to be deleted is not the current one, delete it here.
if (buf != curbuf) {
close_windows(buf, false);
if (buf != curbuf && bufref_valid(&bufref) && buf->b_nwindows <= 0) {
@@ -1386,14 +1361,12 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
}
if (buf == NULL) {
- /* Autocommands must have wiped out all other buffers. Only option
- * now is to make the current buffer empty. */
+ // Autocommands must have wiped out all other buffers. Only option
+ // now is to make the current buffer empty.
return empty_curbuf(false, forceit, action);
}
- /*
- * make buf current buffer
- */
+ // make "buf" the current buffer
if (action == DOBUF_SPLIT) { // split window first
// If 'switchbuf' contains "useopen": jump to first window containing
// "buf" if one exists
@@ -1415,9 +1388,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
return OK;
}
- /*
- * Check if the current buffer may be abandoned.
- */
+ // Check if the current buffer may be abandoned.
if (action == DOBUF_GOTO && !can_abandon(curbuf, forceit)) {
if ((p_confirm || cmdmod.confirm) && p_write) {
bufref_T bufref;
@@ -1510,9 +1481,9 @@ void set_curbuf(buf_T *buf, int action)
}
}
}
- /* An autocommand may have deleted "buf", already entered it (e.g., when
- * it did ":bunload") or aborted the script processing!
- * If curwin->w_buffer is null, enter_buffer() will make it valid again */
+ // An autocommand may have deleted "buf", already entered it (e.g., when
+ // it did ":bunload") or aborted the script processing!
+ // If curwin->w_buffer is null, enter_buffer() will make it valid again
if ((buf_valid(buf) && buf != curbuf
&& !aborting()
) || curwin->w_buffer == NULL) {
@@ -1705,11 +1676,10 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl
fname_expand(curbuf, &ffname, &sfname); // will allocate ffname
- /*
- * If file name already exists in the list, update the entry.
- */
- /* We can use inode numbers when the file exists. Works better
- * for hard links. */
+ // If the file name already exists in the list, update the entry.
+
+ // We can use inode numbers when the file exists. Works better
+ // for hard links.
FileID file_id;
bool file_id_valid = (sfname != NULL
&& os_fileid((char *)sfname, &file_id));
@@ -1841,9 +1811,7 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl
top_file_num = 1;
}
- /*
- * Always copy the options from the current buffer.
- */
+ // Always copy the options from the current buffer.
buf_copy_options(buf, BCO_ALWAYS);
}
@@ -2227,8 +2195,8 @@ int buflist_findpat(const char_u *pattern, const char_u *pattern_end, bool unlis
&& (!diffmode || diff_mode_buf(buf))
&& buflist_match(&regmatch, buf, false) != NULL) {
if (curtab_only) {
- /* Ignore the match if the buffer is not open in
- * the current tab. */
+ // Ignore the match if the buffer is not open in
+ // the current tab.
bool found_window = false;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_buffer == buf) {
@@ -2320,10 +2288,8 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
patc = pat;
}
- /*
- * attempt == 0: try match with '\<', match at start of word
- * attempt == 1: try match without '\<', match anywhere
- */
+ // attempt == 0: try match with '\<', match at start of word
+ // attempt == 1: try match without '\<', match anywhere
for (attempt = 0; attempt <= 1; attempt++) {
if (attempt > 0 && patc == pat) {
break; // there was no anchor, no need to try again
@@ -2338,10 +2304,8 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
return FAIL;
}
- /*
- * round == 1: Count the matches.
- * round == 2: Build the array to keep the matches.
- */
+ // round == 1: Count the matches.
+ // round == 2: Build the array to keep the matches.
for (round = 1; round <= 2; round++) {
count = 0;
FOR_ALL_BUFFERS(buf) {
@@ -2831,11 +2795,9 @@ int setfname(buf_T *buf, char_u *ffname_arg, char_u *sfname_arg, bool message)
return FAIL;
}
- /*
- * if the file name is already used in another buffer:
- * - if the buffer is loaded, fail
- * - if the buffer is not loaded, delete it from the list
- */
+ // If the file name is already used in another buffer:
+ // - if the buffer is loaded, fail
+ // - if the buffer is not loaded, delete it from the list
file_id_valid = os_fileid((char *)ffname, &file_id);
if (!(buf->b_flags & BF_DUMMY)) {
obuf = buflist_findname_file_id(ffname, &file_id, file_id_valid);
@@ -5160,9 +5122,9 @@ void ex_buffer_all(exarg_T *eap)
swap_exists_action = SEA_NONE;
swap_exists_did_quit = true;
- /* Restore the error/interrupt/exception state if not
- * discarded by a new aborting error, interrupt, or uncaught
- * exception. */
+ // Restore the error/interrupt/exception state if not
+ // discarded by a new aborting error, interrupt, or uncaught
+ // exception.
leave_cleanup(&cs);
} else {
handle_swap_exists(NULL);
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 19b0a3c5c6..c0a0376088 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -866,12 +866,7 @@ struct file_buffer {
MarkTree b_marktree[1];
Map(uint64_t, ExtmarkItem) b_extmark_index[1];
Map(uint64_t, ExtmarkNs) b_extmark_ns[1]; // extmark namespaces
-
- VirtLines b_virt_lines;
- uint64_t b_virt_line_mark;
- int b_virt_line_pos;
- bool b_virt_line_above;
- bool b_virt_line_leftcol;
+ size_t b_virt_line_blocks; // number of virt_line blocks
// array of channel_id:s which have asked to receive updates for this
// buffer.
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 4e80528c74..c0f3c32f93 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -91,12 +91,31 @@ void decor_redraw(buf_T *buf, int row1, int row2, Decoration *decor)
if (kv_size(decor->virt_text)) {
redraw_buf_line_later(buf, row1+1);
}
+
+ if (kv_size(decor->virt_lines)) {
+ redraw_buf_line_later(buf, MIN(buf->b_ml.ml_line_count,
+ row1+1+(decor->virt_lines_above?0:1)));
+ }
+}
+
+void decor_remove(buf_T *buf, int row, int row2, Decoration *decor)
+{
+ if (kv_size(decor->virt_lines)) {
+ assert(buf->b_virt_line_blocks > 0);
+ buf->b_virt_line_blocks--;
+ }
+ decor_redraw(buf, row, row2, decor);
+ decor_free(decor);
}
void decor_free(Decoration *decor)
{
if (decor && !decor->shared) {
clear_virttext(&decor->virt_text);
+ for (size_t i = 0; i < kv_size(decor->virt_lines); i++) {
+ clear_virttext(&kv_A(decor->virt_lines, i).line);
+ }
+ kv_destroy(decor->virt_lines);
xfree(decor);
}
}
@@ -118,6 +137,8 @@ Decoration *decor_find_virttext(buf_T *buf, int row, uint64_t ns_id)
mtmark_t mark = marktree_itr_current(itr);
if (mark.row < 0 || mark.row > row) {
break;
+ } else if (marktree_decor_level(mark.id) < kDecorLevelVisible) {
+ goto next_mark;
}
ExtmarkItem *item = map_ref(uint64_t, ExtmarkItem)(buf->b_extmark_index,
mark.id, false);
@@ -125,6 +146,7 @@ Decoration *decor_find_virttext(buf_T *buf, int row, uint64_t ns_id)
&& item->decor && kv_size(item->decor->virt_text)) {
return item->decor;
}
+next_mark:
marktree_itr_next(buf->b_marktree, itr);
}
return NULL;
@@ -158,21 +180,22 @@ bool decor_redraw_start(buf_T *buf, int top_row, DecorState *state)
if (mark.row < 0) { // || mark.row > end_row
break;
}
- if ((mark.row < top_row && mark.id&MARKTREE_END_FLAG)) {
+ if ((mark.row < top_row && mark.id&MARKTREE_END_FLAG)
+ || marktree_decor_level(mark.id) < kDecorLevelVisible) {
goto next_mark;
}
- mtpos_t altpos = marktree_lookup(buf->b_marktree,
- mark.id^MARKTREE_END_FLAG, NULL);
uint64_t start_id = mark.id & ~MARKTREE_END_FLAG;
ExtmarkItem *item = map_ref(uint64_t, ExtmarkItem)(buf->b_extmark_index,
start_id, false);
if (!item || !item->decor) {
- // TODO(bfredl): dedicated flag for being a decoration?
goto next_mark;
}
Decoration *decor = item->decor;
+ mtpos_t altpos = marktree_lookup(buf->b_marktree,
+ mark.id^MARKTREE_END_FLAG, NULL);
+
if ((!(mark.id&MARKTREE_END_FLAG) && altpos.row < top_row
&& !kv_size(decor->virt_text))
|| ((mark.id&MARKTREE_END_FLAG) && altpos.row >= top_row)) {
@@ -251,21 +274,21 @@ int decor_redraw_col(buf_T *buf, int col, int win_col, bool hidden, DecorState *
break;
}
- if ((mark.id&MARKTREE_END_FLAG)) {
- // TODO(bfredl): check decoration flag
+ if ((mark.id&MARKTREE_END_FLAG)
+ || marktree_decor_level(mark.id) < kDecorLevelVisible) {
goto next_mark;
}
- mtpos_t endpos = marktree_lookup(buf->b_marktree,
- mark.id|MARKTREE_END_FLAG, NULL);
ExtmarkItem *item = map_ref(uint64_t, ExtmarkItem)(buf->b_extmark_index,
mark.id, false);
if (!item || !item->decor) {
- // TODO(bfredl): dedicated flag for being a decoration?
goto next_mark;
}
Decoration *decor = item->decor;
+ mtpos_t endpos = marktree_lookup(buf->b_marktree,
+ mark.id|MARKTREE_END_FLAG, NULL);
+
if (endpos.row == -1) {
endpos.row = mark.row;
endpos.col = mark.col;
@@ -414,33 +437,38 @@ void decor_free_all_mem(void)
}
-int decor_virtual_lines(win_T *wp, linenr_T lnum)
+int decor_virt_lines(win_T *wp, linenr_T lnum, VirtLines *lines)
{
buf_T *buf = wp->w_buffer;
- if (!buf->b_virt_line_mark) {
+ if (!buf->b_virt_line_blocks) {
+ // Only pay for what you use: in case virt_lines feature is not active
+ // in a buffer, plines do not need to access the marktree at all
return 0;
}
- if (buf->b_virt_line_pos < 0) {
- mtpos_t pos = marktree_lookup(buf->b_marktree, buf->b_virt_line_mark, NULL);
- if (pos.row < 0) {
- buf->b_virt_line_mark = 0;
+
+ int virt_lines = 0;
+ int row = (int)MAX(lnum - 2, 0);
+ int end_row = (int)lnum;
+ MarkTreeIter itr[1] = { 0 };
+ marktree_itr_get(buf->b_marktree, row, 0, itr);
+ while (true) {
+ mtmark_t mark = marktree_itr_current(itr);
+ if (mark.row < 0 || mark.row >= end_row) {
+ break;
+ } else if (marktree_decor_level(mark.id) < kDecorLevelVirtLine) {
+ goto next_mark;
+ }
+ bool above = mark.row > (int)(lnum - 2);
+ ExtmarkItem *item = map_ref(uint64_t, ExtmarkItem)(buf->b_extmark_index, mark.id, false);
+ if (item && item->decor && item->decor->virt_lines_above == above) {
+ virt_lines += (int)kv_size(item->decor->virt_lines);
+ if (lines) {
+ kv_splice(*lines, item->decor->virt_lines);
+ }
}
- buf->b_virt_line_pos = pos.row + (buf->b_virt_line_above ? 0 : 1);
+next_mark:
+ marktree_itr_next(buf->b_marktree, itr);
}
- return (lnum-1 == buf->b_virt_line_pos) ? (int)kv_size(buf->b_virt_lines) : 0;
-}
-
-void clear_virt_lines(buf_T *buf, int row)
-{
- if (row > -1) {
- redraw_buf_line_later(buf, MIN(buf->b_ml.ml_line_count,
- row+1+(buf->b_virt_line_above?0:1)));
- }
- for (size_t i = 0; i < kv_size(buf->b_virt_lines); i++) {
- clear_virttext(&kv_A(buf->b_virt_lines, i));
- }
- kv_destroy(buf->b_virt_lines); // re-initializes
- buf->b_virt_line_pos = -1;
- buf->b_virt_line_mark = 0;
+ return virt_lines;
}
diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h
index e44fbab0a5..97ae9ed5d8 100644
--- a/src/nvim/decoration.h
+++ b/src/nvim/decoration.h
@@ -24,22 +24,34 @@ typedef enum {
kHlModeBlend,
} HlMode;
+typedef kvec_t(VirtTextChunk) VirtText;
+#define VIRTTEXT_EMPTY ((VirtText)KV_INITIAL_VALUE)
+
+
+typedef kvec_t(struct virt_line { VirtText line; bool left_col; }) VirtLines;
+
+
struct Decoration
{
VirtText virt_text;
+ VirtLines virt_lines;
+
int hl_id; // highlight group
VirtTextPos virt_text_pos;
HlMode hl_mode;
+
+ // TODO(bfredl): at some point turn this into FLAGS
bool virt_text_hide;
bool hl_eol;
bool shared; // shared decoration, don't free
+ bool virt_lines_above;
// TODO(bfredl): style, signs, etc
DecorPriority priority;
int col; // fixed col value, like win_col
int virt_text_width; // width of virt_text
};
-#define DECORATION_INIT { KV_INITIAL_VALUE, 0, kVTEndOfLine, kHlModeUnknown, \
- false, false, false, DECOR_PRIORITY_BASE, 0, 0 }
+#define DECORATION_INIT { KV_INITIAL_VALUE, KV_INITIAL_VALUE, 0, kVTEndOfLine, kHlModeUnknown, \
+ false, false, false, false, DECOR_PRIORITY_BASE, 0, 0 }
typedef struct {
int start_row;
@@ -60,9 +72,7 @@ typedef struct {
int row;
int col_until;
int current;
-
int eol_col;
- VirtText *virt_text;
} DecorState;
typedef struct {
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index b3a08971e9..0cfda53091 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -523,7 +523,7 @@ static int insert_check(VimState *state)
did_cursorhold = false;
}
- // If the cursor was moved we didn't just insert a space */
+ // If the cursor was moved we didn't just insert a space
if (arrow_used) {
s->inserted_space = false;
}
@@ -835,7 +835,7 @@ static int insert_handle_key(InsertState *s)
case Ctrl_C: // End input mode
if (s->c == Ctrl_C && cmdwin_type != 0) {
- // Close the cmdline window. */
+ // Close the cmdline window.
cmdwin_result = K_IGNORE;
got_int = false; // don't stop executing autocommands et al
s->nomove = true;
@@ -6346,8 +6346,8 @@ void auto_format(bool trailblank, bool prev_line)
curwin->w_cursor = pos;
}
- /* With the 'c' flag in 'formatoptions' and 't' missing: only format
- * comments. */
+ // With the 'c' flag in 'formatoptions' and 't' missing: only format
+ // comments.
if (has_format_option(FO_WRAP_COMS) && !has_format_option(FO_WRAP)
&& get_leader_len(old, NULL, false, true) == 0) {
return;
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index e6a3901dcf..b31e1e81d4 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -2026,9 +2026,9 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co
p);
lp->ll_name = lp->ll_exp_name;
if (lp->ll_exp_name == NULL) {
- /* Report an invalid expression in braces, unless the
- * expression evaluation has been cancelled due to an
- * aborting error, an interrupt, or an exception. */
+ // Report an invalid expression in braces, unless the
+ // expression evaluation has been cancelled due to an
+ // aborting error, an interrupt, or an exception.
if (!aborting() && !quiet) {
emsg_severe = true;
EMSG2(_(e_invarg2), name);
@@ -2173,9 +2173,9 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co
lp->ll_dict = lp->ll_tv->vval.v_dict;
lp->ll_di = tv_dict_find(lp->ll_dict, (const char *)key, len);
- /* When assigning to a scope dictionary check that a function and
- * variable name is valid (only variable name unless it is l: or
- * g: dictionary). Disallow overwriting a builtin function. */
+ // When assigning to a scope dictionary check that a function and
+ // variable name is valid (only variable name unless it is l: or
+ // g: dictionary). Disallow overwriting a builtin function.
if (rettv != NULL && lp->ll_dict->dv_scope != 0) {
int prevval;
int wrong;
@@ -2758,8 +2758,8 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx)
xp->xp_context = EXPAND_EXPRESSION;
}
} else {
- /* Doesn't look like something valid, expand as an expression
- * anyway. */
+ // Doesn't look like something valid, expand as an expression
+ // anyway.
xp->xp_context = EXPAND_EXPRESSION;
}
arg = xp->xp_pattern;
@@ -4927,9 +4927,9 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
++p;
nr = (nr << 4) + hex2nr(*p);
}
- ++p;
- /* For "\u" store the number according to
- * 'encoding'. */
+ p++;
+ // For "\u" store the number according to
+ // 'encoding'.
if (c != 'X') {
name += utf_char2bytes(nr, name);
} else {
@@ -8452,7 +8452,7 @@ const char_u *find_name_end(const char_u *arg, const char_u **expr_start, const
}
} else if (br_nest == 0 && mb_nest == 0 && *p == ':') {
// "s:" is start of "s:var", but "n:" is not and can be used in
- // slice "[n:]". Also "xx:" is not a namespace. But {ns}: is. */
+ // slice "[n:]". Also "xx:" is not a namespace. But {ns}: is.
len = (int)(p - arg);
if ((len > 1 && p[-1] != '}')
|| (len == 1 && vim_strchr(namespace_char, *arg) == NULL)) {
@@ -9825,12 +9825,12 @@ void ex_echo(exarg_T *eap)
if (!eap->skip) {
if (atstart) {
atstart = false;
- /* Call msg_start() after eval1(), evaluating the expression
- * may cause a message to appear. */
+ // Call msg_start() after eval1(), evaluating the expression
+ // may cause a message to appear.
if (eap->cmdidx == CMD_echo) {
- /* Mark the saved text as finishing the line, so that what
- * follows is displayed on a new line when scrolling back
- * at the more prompt. */
+ // Mark the saved text as finishing the line, so that what
+ // follows is displayed on a new line when scrolling back
+ // at the more prompt.
msg_sb_eol();
msg_start();
}
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index f4393a79dc..3c7532df7b 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -1720,8 +1720,8 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
return (char_u *)xmemdupz(start, len);
}
- /* A name starting with "<SID>" or "<SNR>" is local to a script. But
- * don't skip over "s:", get_lval() needs it for "s:dict.func". */
+ // A name starting with "<SID>" or "<SNR>" is local to a script. But
+ // don't skip over "s:", get_lval() needs it for "s:dict.func".
lead = eval_fname_script((const char *)start);
if (lead > 2) {
start += lead;
@@ -2405,14 +2405,14 @@ void ex_function(exarg_T *eap)
// Add the line to the function.
ga_grow(&newlines, 1 + sourcing_lnum_off);
- /* Copy the line to newly allocated memory. get_one_sourceline()
- * allocates 250 bytes per line, this saves 80% on average. The cost
- * is an extra alloc/free. */
+ // Copy the line to newly allocated memory. get_one_sourceline()
+ // allocates 250 bytes per line, this saves 80% on average. The cost
+ // is an extra alloc/free.
p = vim_strsave(theline);
((char_u **)(newlines.ga_data))[newlines.ga_len++] = p;
- /* Add NULL lines for continuation lines, so that the line count is
- * equal to the index in the growarray. */
+ // Add NULL lines for continuation lines, so that the line count is
+ // equal to the index in the growarray.
while (sourcing_lnum_off-- > 0) {
((char_u **)(newlines.ga_data))[newlines.ga_len++] = NULL;
}
@@ -2490,8 +2490,8 @@ void ex_function(exarg_T *eap)
goto erret;
}
- /* Give the function a sequential number. Can only be used with a
- * Funcref! */
+ // Give the function a sequential number. Can only be used with a
+ // Funcref!
xfree(name);
sprintf(numbuf, "%d", ++func_nr);
name = vim_strsave((char_u *)numbuf);
@@ -3079,13 +3079,13 @@ int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv)
cstack->cs_pending[idx] = CSTP_RETURN;
if (!is_cmd && !reanimate) {
- /* A pending return again gets pending. "rettv" points to an
- * allocated variable with the rettv of the original ":return"'s
- * argument if present or is NULL else. */
+ // A pending return again gets pending. "rettv" points to an
+ // allocated variable with the rettv of the original ":return"'s
+ // argument if present or is NULL else.
cstack->cs_rettv[idx] = rettv;
} else {
- /* When undoing a return in order to make it pending, get the stored
- * return rettv. */
+ // When undoing a return in order to make it pending, get the stored
+ // return rettv.
if (reanimate) {
assert(current_funccal->rettv);
rettv = current_funccal->rettv;
@@ -3214,8 +3214,8 @@ int func_has_ended(void *cookie)
{
funccall_T *fcp = (funccall_T *)cookie;
- /* Ignore the "abort" flag if the abortion behavior has been changed due to
- * an error inside a try conditional. */
+ // Ignore the "abort" flag if the abortion behavior has been changed due to
+ // an error inside a try conditional.
return ((fcp->func->uf_flags & FC_ABORT) && did_emsg && !aborted_in_try())
|| fcp->returned;
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 4a23f284cc..558001cd62 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1082,8 +1082,8 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
curwin->w_cursor.lnum = n;
while (line1 <= line2) {
- /* need to use vim_strsave() because the line will be unlocked within
- * ml_append() */
+ // need to use vim_strsave() because the line will be unlocked within
+ // ml_append()
p = vim_strsave(ml_get(line1));
ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, false);
xfree(p);
@@ -1206,9 +1206,9 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
prevcmd = newcmd;
if (bangredo) { // put cmd in redo buffer for ! command
- /* If % or # appears in the command, it must have been escaped.
- * Reescape them, so that redoing them does not substitute them by the
- * buffername. */
+ // If % or # appears in the command, it must have been escaped.
+ // Reescape them, so that redoing them does not substitute them by the
+ // buffername.
char_u *cmd = vim_strsave_escaped(prevcmd, (char_u *)"%#");
AppendToRedobuffLit(cmd, -1);
@@ -1237,8 +1237,8 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
do_shell(newcmd, 0);
} else { // :range!
- /* Careful: This may recursively call do_bang() again! (because of
- * autocommands) */
+ // Careful: This may recursively call do_bang() again! (because of
+ // autocommands)
do_filter(line1, line2, eap, newcmd, do_in, do_out);
apply_autocmds(EVENT_SHELLFILTERPOST, NULL, NULL, false, curbuf);
}
@@ -1368,9 +1368,9 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
did_check_timestamps = FALSE;
need_check_timestamps = TRUE;
- /* When interrupting the shell command, it may still have produced some
- * useful output. Reset got_int here, so that readfile() won't cancel
- * reading. */
+ // When interrupting the shell command, it may still have produced some
+ // useful output. Reset got_int here, so that readfile() won't cancel
+ // reading.
os_breakcheck();
got_int = FALSE;
@@ -1837,8 +1837,8 @@ int do_write(exarg_T *eap)
alt_buf = buflist_findname(ffname);
}
if (alt_buf != NULL && alt_buf->b_ml.ml_mfp != NULL) {
- /* Overwriting a file that is loaded in another buffer is not a
- * good idea. */
+ // Overwriting a file that is loaded in another buffer is not a
+ // good idea.
EMSG(_(e_bufloaded));
goto theend;
}
@@ -2143,8 +2143,8 @@ int not_writing(void)
*/
static int check_readonly(int *forceit, buf_T *buf)
{
- /* Handle a file being readonly when the 'readonly' option is set or when
- * the file exists and permissions are read-only. */
+ // Handle a file being readonly when the 'readonly' option is set or when
+ // the file exists and permissions are read-only.
if (!*forceit && (buf->b_p_ro
|| (os_path_exists(buf->b_ffname)
&& !os_file_is_writable((char *)buf->b_ffname)))) {
@@ -2279,6 +2279,7 @@ theend:
/// ECMD_ADDBUF: don't edit, just add to buffer list
/// ECMD_ALTBUF: like ECMD_ADDBUF and also set the alternate
/// file
+/// ECMD_NOWINENTER: Do not trigger BufWinEnter
/// @param oldwin Should be "curwin" when editing a new buffer in the current
/// window, NULL when splitting the window first. When not NULL
/// info of the previous buffer for "oldwin" is stored.
@@ -2612,8 +2613,8 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
set_buflisted(TRUE);
}
- /* If autocommands change buffers under our fingers, forget about
- * editing the file. */
+ // If autocommands change buffers under our fingers, forget about
+ // editing the file.
if (buf != curbuf) {
goto theend;
}
@@ -2677,9 +2678,9 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
}
xfree(new_name);
- /* If autocommands change buffers under our fingers, forget about
- * re-editing the file. Should do the buf_clear_file(), but perhaps
- * the autocommands changed the buffer... */
+ // If autocommands change buffers under our fingers, forget about
+ // re-editing the file. Should do the buf_clear_file(), but perhaps
+ // the autocommands changed the buffer...
if (buf != curbuf) {
goto theend;
}
@@ -2711,8 +2712,8 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
*/
curwin_init();
- /* It's possible that all lines in the buffer changed. Need to update
- * automatic folding for all windows where it's used. */
+ // It's possible that all lines in the buffer changed. Need to update
+ // automatic folding for all windows where it's used.
FOR_ALL_TAB_WINDOWS(tp, win) {
if (win->w_buffer == curbuf) {
foldUpdateAll(win);
@@ -2735,7 +2736,10 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
/*
* Open the buffer and read the file.
*/
- if (should_abort(open_buffer(FALSE, eap, readfile_flags))) {
+ if (flags & ECMD_NOWINENTER) {
+ readfile_flags |= READ_NOWINENTER;
+ }
+ if (should_abort(open_buffer(false, eap, readfile_flags))) {
retval = FAIL;
}
@@ -2744,15 +2748,17 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
}
handle_swap_exists(&old_curbuf);
} else {
- /* Read the modelines, but only to set window-local options. Any
- * buffer-local options have already been set and may have been
- * changed by the user. */
+ // Read the modelines, but only to set window-local options. Any
+ // buffer-local options have already been set and may have been
+ // changed by the user.
do_modelines(OPT_WINONLY);
apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf,
&retval);
- apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf,
- &retval);
+ if ((flags & ECMD_NOWINENTER) == 0) {
+ apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, false, curbuf,
+ &retval);
+ }
}
check_arg_idx(curwin);
@@ -2778,16 +2784,16 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
maketitle();
}
- /* Tell the diff stuff that this buffer is new and/or needs updating.
- * Also needed when re-editing the same buffer, because unloading will
- * have removed it as a diff buffer. */
+ // Tell the diff stuff that this buffer is new and/or needs updating.
+ // Also needed when re-editing the same buffer, because unloading will
+ // have removed it as a diff buffer.
if (curwin->w_p_diff) {
diff_buf_add(curbuf);
diff_invalidate(curbuf);
}
- /* If the window options were changed may need to set the spell language.
- * Can only do this after the buffer has been properly setup. */
+ // If the window options were changed may need to set the spell language.
+ // Can only do this after the buffer has been properly setup.
if (did_get_winopts && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) {
(void)did_set_spelllang(curwin);
}
@@ -3022,10 +3028,10 @@ void ex_append(exarg_T *eap)
curbuf->b_p_ai = !curbuf->b_p_ai;
}
- /* "start" is set to eap->line2+1 unless that position is invalid (when
- * eap->line2 pointed to the end of the buffer and nothing was appended)
- * "end" is set to lnum when something has been appended, otherwise
- * it is the same than "start" -- Acevedo */
+ // "start" is set to eap->line2+1 unless that position is invalid (when
+ // eap->line2 pointed to the end of the buffer and nothing was appended)
+ // "end" is set to lnum when something has been appended, otherwise
+ // it is the same than "start" -- Acevedo
curbuf->b_op_start.lnum = (eap->line2 < curbuf->b_ml.ml_line_count) ?
eap->line2 + 1 : curbuf->b_ml.ml_line_count;
if (eap->cmdidx != CMD_append) {
@@ -3555,8 +3561,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
pat = NULL; // search_regcomp() will use previous pattern
sub = (char_u *)old_sub.sub;
- /* Vi compatibility quirk: repeating with ":s" keeps the cursor in the
- * last column after using "$". */
+ // Vi compatibility quirk: repeating with ":s" keeps the cursor in the
+ // last column after using "$".
endcolumn = (curwin->w_curswant == MAXCOL);
}
@@ -3807,8 +3813,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
if (subflags.do_ask && !preview) {
int typed = 0;
- /* change State to CONFIRM, so that the mouse works
- * properly */
+ // change State to CONFIRM, so that the mouse works
+ // properly
int save_State = State;
State = CONFIRM;
setmouse(); // disable mouse in xterm
@@ -3864,9 +3870,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
const bool save_p_lz = p_lz;
int save_p_fen = curwin->w_p_fen;
- curwin->w_p_fen = FALSE;
- /* Invert the matched string.
- * Remove the inversion afterwards. */
+ curwin->w_p_fen = false;
+ // Invert the matched string.
+ // Remove the inversion afterwards.
int temp = RedrawingDisabled;
RedrawingDisabled = 0;
@@ -3874,11 +3880,11 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
p_lz = false;
if (new_start != NULL) {
- /* There already was a substitution, we would
- * like to show this to the user. We cannot
- * really update the line, it would change
- * what matches. Temporarily replace the line
- * and change it back afterwards. */
+ // There already was a substitution, we would
+ // like to show this to the user. We cannot
+ // really update the line, it would change
+ // what matches. Temporarily replace the line
+ // and change it back afterwards.
orig_line = vim_strsave(ml_get(lnum));
char_u *new_line = concat_str(new_start, sub_firstline + copycol);
@@ -3908,8 +3914,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
}
msg_starthere();
i = msg_scroll;
- msg_scroll = 0; /* truncate msg when
- needed */
+ msg_scroll = 0; // truncate msg when
+ // needed
msg_no_more = true;
msg_ext_set_kind("confirm_sub");
smsg_attr(HL_ATTR(HLF_R), // Same highlight as wait_return().
@@ -4878,8 +4884,8 @@ void ex_help(exarg_T *eap)
if (!p_im) {
restart_edit = 0; // don't want insert mode in help file
}
- /* Restore KeyTyped, setting 'filetype=help' may reset it.
- * It is needed for do_tag top open folds under the cursor. */
+ // Restore KeyTyped, setting 'filetype=help' may reset it.
+ // It is needed for do_tag top open folds under the cursor.
KeyTyped = old_KeyTyped;
do_tag(tag, DT_HELP, 1, FALSE, TRUE);
@@ -5073,11 +5079,10 @@ int find_help_tags(const char_u *arg, int *num_matches, char_u ***matches, bool
STRCPY(d + 4, "\\$");
}
} else {
- /* Replace:
- * "[:...:]" with "\[:...:]"
- * "[++...]" with "\[++...]"
- * "\{" with "\\{" -- matching "} \}"
- */
+ // Replace:
+ // "[:...:]" with "\[:...:]"
+ // "[++...]" with "\[++...]"
+ // "\{" with "\\{" -- matching "} \}"
if ((arg[0] == '[' && (arg[1] == ':'
|| (arg[1] == '+' && arg[2] == '+')))
|| (arg[0] == '\\' && arg[1] == '{')) {
@@ -5327,8 +5332,8 @@ void fix_help_buffer(void)
continue;
}
- /* Go through all directories in 'runtimepath', skipping
- * $VIMRUNTIME. */
+ // Go through all directories in 'runtimepath', skipping
+ // $VIMRUNTIME.
char_u *p = p_rtp;
while (*p != NUL) {
copy_option_part(&p, NameBuff, MAXPATHL, ",");
@@ -5413,10 +5418,9 @@ void fix_help_buffer(void)
if (*s == '\r' || *s == '\n') {
*s = NUL;
}
- /* The text is utf-8 when a byte
- * above 127 is found and no
- * illegal byte sequence is found.
- */
+ // The text is utf-8 when a byte
+ // above 127 is found and no
+ // illegal byte sequence is found.
if (*s >= 0x80 && this_utf != kFalse) {
this_utf = kTrue;
const int l = utf_ptr2len(s);
@@ -5427,9 +5431,9 @@ void fix_help_buffer(void)
}
++s;
}
- /* The help file is latin1 or utf-8;
- * conversion to the current
- * 'encoding' may be required. */
+ // The help file is latin1 or utf-8;
+ // conversion to the current
+ // 'encoding' may be required.
vc.vc_type = CONV_NONE;
convert_setup(&vc,
(char_u *)(this_utf == kTrue ? "utf-8" : "latin1"),
@@ -5716,8 +5720,8 @@ static void do_helptags(char_u *dirname, bool add_help_tags, bool ignore_writeer
return;
}
- /* Go over all files in the directory to find out what languages are
- * present. */
+ // Go over all files in the directory to find out what languages are
+ // present.
int j;
ga_init(&ga, 1, 10);
for (int i = 0; i < filecount; i++) {
diff --git a/src/nvim/ex_cmds.h b/src/nvim/ex_cmds.h
index c34ffa1d3b..241674c24c 100644
--- a/src/nvim/ex_cmds.h
+++ b/src/nvim/ex_cmds.h
@@ -16,7 +16,8 @@
#define ECMD_OLDBUF 0x04 // use existing buffer if it exists
#define ECMD_FORCEIT 0x08 // ! used in Ex command
#define ECMD_ADDBUF 0x10 // don't edit, just add to buffer list
-#define ECMD_ALTBUF 0x20 // like ECMD_ADDBUF and set the alternate file
+#define ECMD_ALTBUF 0x20 // like ECMD_ADDBUF and set the alternate file
+#define ECMD_NOWINENTER 0x40 // do not trigger BufWinEnter
// for lnum argument in do_ecmd()
#define ECMD_LASTL (linenr_T)0 // use last position in loaded file
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 68dd4a22ff..532f8aa9b3 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -340,12 +340,12 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
int getline_is_func;
static int call_depth = 0; // recursiveness
- /* For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory
- * location for storing error messages to be converted to an exception.
- * This ensures that the do_errthrow() call in do_one_cmd() does not
- * combine the messages stored by an earlier invocation of do_one_cmd()
- * with the command name of the later one. This would happen when
- * BufWritePost autocommands are executed after a write error. */
+ // For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory
+ // location for storing error messages to be converted to an exception.
+ // This ensures that the do_errthrow() call in do_one_cmd() does not
+ // combine the messages stored by an earlier invocation of do_one_cmd()
+ // with the command name of the later one. This would happen when
+ // BufWritePost autocommands are executed after a write error.
saved_msg_list = msg_list;
msg_list = &private_msg_list;
private_msg_list = NULL;
@@ -445,12 +445,12 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
// 1. If repeating, get a previous line from lines_ga.
if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) {
- /* Each '|' separated command is stored separately in lines_ga, to
- * be able to jump to it. Don't use next_cmdline now. */
+ // Each '|' separated command is stored separately in lines_ga, to
+ // be able to jump to it. Don't use next_cmdline now.
XFREE_CLEAR(cmdline_copy);
- /* Check if a function has returned or, unless it has an unclosed
- * try conditional, aborted. */
+ // Check if a function has returned or, unless it has an unclosed
+ // try conditional, aborted.
if (getline_is_func) {
if (do_profiling == PROF_YES) {
func_line_end(real_cookie);
@@ -630,8 +630,8 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
new_last_cmdline = NULL;
}
} else {
- /* need to copy the command after the '|' to cmdline_copy, for the
- * next do_one_cmd() */
+ // need to copy the command after the '|' to cmdline_copy, for the
+ // next do_one_cmd()
STRMOVE(cmdline_copy, next_cmdline);
next_cmdline = cmdline_copy;
}
@@ -656,10 +656,10 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) {
cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP);
- /* Jump back to the matching ":while" or ":for". Be careful
- * not to use a cs_line[] from an entry that isn't a ":while"
- * or ":for": It would make "current_line" invalid and can
- * cause a crash. */
+ // Jump back to the matching ":while" or ":for". Be careful
+ // not to use a cs_line[] from an entry that isn't a ":while"
+ // or ":for": It would make "current_line" invalid and can
+ // cause a crash.
if (!did_emsg && !got_int && !current_exception
&& cstack.cs_idx >= 0
&& (cstack.cs_flags[cstack.cs_idx]
@@ -752,9 +752,9 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
while (!((got_int || (did_emsg && force_abort) || current_exception)
&& cstack.cs_trylevel == 0)
&& !(did_emsg
- /* Keep going when inside try/catch, so that the error can be
- * deal with, except when it is a syntax error, it may cause
- * the :endtry to be missed. */
+ // Keep going when inside try/catch, so that the error can be
+ // deal with, except when it is a syntax error, it may cause
+ // the :endtry to be missed.
&& (cstack.cs_trylevel == 0 || did_emsg_syntax)
&& used_getline
&& getline_equal(fgetline, cookie, getexline))
@@ -2880,8 +2880,8 @@ int cmd_exists(const char *const name)
}
}
- /* Check built-in commands and user defined commands.
- * For ":2match" and ":3match" we need to skip the number. */
+ // Check built-in commands and user defined commands.
+ // For ":2match" and ":3match" we need to skip the number.
ea.cmd = (char_u *)((*name == '2' || *name == '3') ? name + 1 : name);
ea.cmdidx = (cmdidx_T)0;
int full = false;
@@ -3964,8 +3964,8 @@ static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, in
if (skip) {
++cmd;
} else {
- /* Only accept a mark in another file when it is
- * used by itself: ":'M". */
+ // Only accept a mark in another file when it is
+ // used by itself: ":'M".
fp = getmark(*cmd, to_other_file && cmd[1] == NUL);
++cmd;
if (fp == (pos_T *)-1) {
@@ -4445,11 +4445,10 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
xfree(l);
}
- /* Need to escape white space et al. with a backslash.
- * Don't do this for:
- * - replacement that already has been escaped: "##"
- * - shell commands (may have to use quotes instead).
- */
+ // Need to escape white space et al. with a backslash.
+ // Don't do this for:
+ // - replacement that already has been escaped: "##"
+ // - shell commands (may have to use quotes instead).
if (!eap->usefilter
&& !escaped
&& eap->cmdidx != CMD_bang
@@ -4795,8 +4794,8 @@ static int getargopt(exarg_T *eap)
*p = TOLOWER_ASC(*p);
}
} else {
- /* Check ++bad= argument. Must be a single-byte character, "keep" or
- * "drop". */
+ // Check ++bad= argument. Must be a single-byte character, "keep" or
+ // "drop".
if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) {
return FAIL;
}
@@ -6773,15 +6772,15 @@ void tabpage_close_other(tabpage_T *tp, int forceit)
int h = tabline_height();
char_u prev_idx[NUMBUFLEN];
- /* Limit to 1000 windows, autocommands may add a window while we close
- * one. OK, so I'm paranoid... */
+ // Limit to 1000 windows, autocommands may add a window while we close
+ // one. OK, so I'm paranoid...
while (++done < 1000) {
snprintf((char *)prev_idx, sizeof(prev_idx), "%i", tabpage_index(tp));
wp = tp->tp_lastwin;
ex_win_close(forceit, wp, tp);
- /* Autocommands may delete the tab page under our fingers and we may
- * fail to close a window with a modified buffer. */
+ // Autocommands may delete the tab page under our fingers and we may
+ // fail to close a window with a modified buffer.
if (!valid_tabpage(tp) || tp->tp_firstwin == wp) {
break;
}
@@ -7167,8 +7166,8 @@ void ex_splitview(exarg_T *eap)
|| eap->cmdidx == CMD_tabfind
|| eap->cmdidx == CMD_tabnew;
- /* A ":split" in the quickfix window works like ":new". Don't want two
- * quickfix windows. But it's OK when doing ":tab split". */
+ // A ":split" in the quickfix window works like ":new". Don't want two
+ // quickfix windows. But it's OK when doing ":tab split".
if (bt_quickfix(curbuf) && cmdmod.tab == 0) {
if (eap->cmdidx == CMD_split) {
eap->cmdidx = CMD_new;
@@ -7515,18 +7514,18 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
enter_cleanup(&cs);
win_close(curwin, !need_hide && !buf_hide(curbuf));
- /* Restore the error/interrupt/exception state if not
- * discarded by a new aborting error, interrupt, or
- * uncaught exception. */
+ // Restore the error/interrupt/exception state if not
+ // discarded by a new aborting error, interrupt, or
+ // uncaught exception.
leave_cleanup(&cs);
}
}
} else if (readonlymode && curbuf->b_nwindows == 1) {
- /* When editing an already visited buffer, 'readonly' won't be set
- * but the previous value is kept. With ":view" and ":sview" we
- * want the file to be readonly, except when another window is
- * editing the same buffer. */
- curbuf->b_p_ro = TRUE;
+ // When editing an already visited buffer, 'readonly' won't be set
+ // but the previous value is kept. With ":view" and ":sview" we
+ // want the file to be readonly, except when another window is
+ // editing the same buffer.
+ curbuf->b_p_ro = true;
}
readonlymode = n;
} else {
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 09a1350f17..3deb09241c 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -406,9 +406,9 @@ char_u *get_exception_string(void *value, except_type_T type, char_u *cmdname, i
val = ret + 4;
}
- /* msg_add_fname may have been used to prefix the message with a file
- * name in quotes. In the exception value, put the file name in
- * parentheses and move it to the end. */
+ // msg_add_fname may have been used to prefix the message with a file
+ // name in quotes. In the exception value, put the file name in
+ // parentheses and move it to the end.
for (p = mesg;; p++) {
if (*p == NUL
|| (*p == 'E'
@@ -922,16 +922,14 @@ void ex_else(exarg_T *eap)
cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE;
}
- /*
- * When debugging or a breakpoint was encountered, display the debug prompt
- * (if not already done). This shows the user that an ":else" or ":elseif"
- * is executed when the ":if" or previous ":elseif" was not TRUE. Handle
- * a ">quit" debug command as if an interrupt had occurred before the
- * ":else" or ":elseif". That is, set "skip" and throw an interrupt
- * exception if appropriate. Doing this here prevents that an exception
- * for a parsing errors is discarded when throwing the interrupt exception
- * later on.
- */
+ // When debugging or a breakpoint was encountered, display the debug prompt
+ // (if not already done). This shows the user that an ":else" or ":elseif"
+ // is executed when the ":if" or previous ":elseif" was not TRUE. Handle
+ // a ">quit" debug command as if an interrupt had occurred before the
+ // ":else" or ":elseif". That is, set "skip" and throw an interrupt
+ // exception if appropriate. Doing this here prevents that an exception
+ // for a parsing errors is discarded when throwing the interrupt exception
+ // later on.
if (!skip && dbg_check_skipped(eap) && got_int) {
(void)do_intthrow(cstack);
skip = TRUE;
@@ -1055,11 +1053,11 @@ void ex_continue(exarg_T *eap)
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = (char_u *)N_("E586: :continue without :while or :for");
} else {
- /* Try to find the matching ":while". This might stop at a try
- * conditional not in its finally clause (which is then to be executed
- * next). Therefore, deactivate all conditionals except the ":while"
- * itself (if reached). */
- idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
+ // Try to find the matching ":while". This might stop at a try
+ // conditional not in its finally clause (which is then to be executed
+ // next). Therefore, deactivate all conditionals except the ":while"
+ // itself (if reached).
+ idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, false);
assert(idx >= 0);
if (cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)) {
rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel);
@@ -1070,8 +1068,8 @@ void ex_continue(exarg_T *eap)
*/
cstack->cs_lflags |= CSL_HAD_CONT; // let do_cmdline() handle it
} else {
- /* If a try conditional not in its finally clause is reached first,
- * make the ":continue" pending for execution at the ":endtry". */
+ // If a try conditional not in its finally clause is reached first,
+ // make the ":continue" pending for execution at the ":endtry".
cstack->cs_pending[idx] = CSTP_CONTINUE;
report_make_pending(CSTP_CONTINUE, NULL);
}
@@ -1092,7 +1090,7 @@ void ex_break(exarg_T *eap)
// Deactivate conditionals until the matching ":while" or a try
// conditional not in its finally clause (which is then to be
// executed next) is found. In the latter case, make the ":break"
- // pending for execution at the ":endtry". */
+ // pending for execution at the ":endtry".
idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, true);
if (idx >= 0 && !(cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR))) {
cstack->cs_pending[idx] = CSTP_BREAK;
@@ -1155,20 +1153,17 @@ void ex_endwhile(exarg_T *eap)
// Cleanup and rewind all contained (and unclosed) conditionals.
(void)cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel);
- }
- /*
- * When debugging or a breakpoint was encountered, display the debug
- * prompt (if not already done). This shows the user that an
- * ":endwhile"/":endfor" is executed when the ":while" was not TRUE or
- * after a ":break". Handle a ">quit" debug command as if an
- * interrupt had occurred before the ":endwhile"/":endfor". That is,
- * throw an interrupt exception if appropriate. Doing this here
- * prevents that an exception for a parsing error is discarded when
- * throwing the interrupt exception later on.
- */
- else if (cstack->cs_flags[cstack->cs_idx] & CSF_TRUE
- && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)
- && dbg_check_skipped(eap)) {
+ } else if (cstack->cs_flags[cstack->cs_idx] & CSF_TRUE
+ && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)
+ && dbg_check_skipped(eap)) {
+ // When debugging or a breakpoint was encountered, display the debug
+ // prompt (if not already done). This shows the user that an
+ // ":endwhile"/":endfor" is executed when the ":while" was not TRUE or
+ // after a ":break". Handle a ">quit" debug command as if an
+ // interrupt had occurred before the ":endwhile"/":endfor". That is,
+ // throw an interrupt exception if appropriate. Doing this here
+ // prevents that an exception for a parsing error is discarded when
+ // throwing the interrupt exception later on.
(void)do_intthrow(cstack);
}
@@ -1354,8 +1349,8 @@ void ex_catch(exarg_T *eap)
}
}
if (cstack->cs_flags[idx] & CSF_FINALLY) {
- /* Give up for a ":catch" after ":finally" and ignore it.
- * Just parse. */
+ // Give up for a ":catch" after ":finally" and ignore it.
+ // Just parse.
eap->errmsg = (char_u *)N_("E604: :catch after :finally");
give_up = TRUE;
} else {
@@ -1395,16 +1390,16 @@ void ex_catch(exarg_T *eap)
return;
}
- /* When debugging or a breakpoint was encountered, display the
- * debug prompt (if not already done) before checking for a match.
- * This is a helpful hint for the user when the regular expression
- * matching fails. Handle a ">quit" debug command as if an
- * interrupt had occurred before the ":catch". That is, discard
- * the original exception, replace it by an interrupt exception,
- * and don't catch it in this try block. */
+ // When debugging or a breakpoint was encountered, display the
+ // debug prompt (if not already done) before checking for a match.
+ // This is a helpful hint for the user when the regular expression
+ // matching fails. Handle a ">quit" debug command as if an
+ // interrupt had occurred before the ":catch". That is, discard
+ // the original exception, replace it by an interrupt exception,
+ // and don't catch it in this try block.
if (!dbg_check_skipped(eap) || !do_intthrow(cstack)) {
- /* Terminate the pattern and avoid the 'l' flag in 'cpoptions'
- * while compiling it. */
+ // Terminate the pattern and avoid the 'l' flag in 'cpoptions'
+ // while compiling it.
if (end != NULL) {
save_char = *end;
*end = NUL;
@@ -1440,16 +1435,16 @@ void ex_catch(exarg_T *eap)
}
if (caught) {
- /* Make this ":catch" clause active and reset did_emsg and got_int.
- * Put the exception on the caught stack. */
+ // Make this ":catch" clause active and reset did_emsg and got_int.
+ // Put the exception on the caught stack.
cstack->cs_flags[idx] |= CSF_ACTIVE | CSF_CAUGHT;
did_emsg = got_int = false;
catch_exception((except_T *)cstack->cs_exception[idx]);
- /* It's mandatory that the current exception is stored in the cstack
- * so that it can be discarded at the next ":catch", ":finally", or
- * ":endtry" or when the catch clause is left by a ":continue",
- * ":break", ":return", ":finish", error, interrupt, or another
- * exception. */
+ // It's mandatory that the current exception is stored in the cstack
+ // so that it can be discarded at the next ":catch", ":finally", or
+ // ":endtry" or when the catch clause is left by a ":continue",
+ // ":break", ":return", ":finish", error, interrupt, or another
+ // exception.
if (cstack->cs_exception[cstack->cs_idx] != current_exception) {
internal_error("ex_catch()");
}
@@ -1576,13 +1571,13 @@ void ex_finally(exarg_T *eap)
assert(pending >= CHAR_MIN && pending <= CHAR_MAX);
cstack->cs_pending[cstack->cs_idx] = (char)pending;
- /* It's mandatory that the current exception is stored in the
- * cstack so that it can be rethrown at the ":endtry" or be
- * discarded if the finally clause is left by a ":continue",
- * ":break", ":return", ":finish", error, interrupt, or another
- * exception. When emsg() is called for a missing ":endif" or
- * a missing ":endwhile"/":endfor" detected here, the
- * exception will be discarded. */
+ // It's mandatory that the current exception is stored in the
+ // cstack so that it can be rethrown at the ":endtry" or be
+ // discarded if the finally clause is left by a ":continue",
+ // ":break", ":return", ":finish", error, interrupt, or another
+ // exception. When emsg() is called for a missing ":endif" or
+ // a missing ":endwhile"/":endfor" detected here, the
+ // exception will be discarded.
if (current_exception
&& cstack->cs_exception[cstack->cs_idx] != current_exception) {
internal_error("ex_finally()");
@@ -1666,21 +1661,20 @@ void ex_endtry(exarg_T *eap)
}
}
- /* If there was no finally clause, show the user when debugging or
- * a breakpoint was encountered that the end of the try conditional has
- * been reached: display the debug prompt (if not already done). Do
- * this on normal control flow or when an exception was thrown, but not
- * on an interrupt or error not converted to an exception or when
- * a ":break", ":continue", ":return", or ":finish" is pending. These
- * actions are carried out immediately.
- */
+ // If there was no finally clause, show the user when debugging or
+ // a breakpoint was encountered that the end of the try conditional has
+ // been reached: display the debug prompt (if not already done). Do
+ // this on normal control flow or when an exception was thrown, but not
+ // on an interrupt or error not converted to an exception or when
+ // a ":break", ":continue", ":return", or ":finish" is pending. These
+ // actions are carried out immediately.
if ((rethrow || (!skip
&& !(cstack->cs_flags[idx] & CSF_FINALLY)
&& !cstack->cs_pending[idx]))
&& dbg_check_skipped(eap)) {
- /* Handle a ">quit" debug command as if an interrupt had occurred
- * before the ":endtry". That is, throw an interrupt exception and
- * set "skip" and "rethrow". */
+ // Handle a ">quit" debug command as if an interrupt had occurred
+ // before the ":endtry". That is, throw an interrupt exception and
+ // set "skip" and "rethrow".
if (got_int) {
skip = TRUE;
(void)do_intthrow(cstack);
@@ -1815,13 +1809,12 @@ void enter_cleanup(cleanup_T *csp)
| (current_exception ? CSTP_THROW : 0)
| (need_rethrow ? CSTP_THROW : 0);
- /* If we are currently throwing an exception, save it as well. On an error
- * not yet converted to an exception, update "force_abort" and reset
- * "cause_abort" (as do_errthrow() would do). This is needed for the
- * do_cmdline() call that is going to be made for autocommand execution. We
- * need not save *msg_list because there is an extra instance for every call
- * of do_cmdline(), anyway.
- */
+ // If we are currently throwing an exception, save it as well. On an error
+ // not yet converted to an exception, update "force_abort" and reset
+ // "cause_abort" (as do_errthrow() would do). This is needed for the
+ // do_cmdline() call that is going to be made for autocommand execution. We
+ // need not save *msg_list because there is an extra instance for every call
+ // of do_cmdline(), anyway.
if (current_exception || need_rethrow) {
csp->exception = current_exception;
current_exception = NULL;
@@ -1897,13 +1890,10 @@ void leave_cleanup(cleanup_T *csp)
*/
if (pending & CSTP_THROW) {
current_exception = csp->exception;
- }
- /*
- * If an error was about to be converted to an exception when
- * enter_cleanup() was called, let "cause_abort" take the part of
- * "force_abort" (as done by cause_errthrow()).
- */
- else if (pending & CSTP_ERROR) {
+ } else if (pending & CSTP_ERROR) {
+ // If an error was about to be converted to an exception when
+ // enter_cleanup() was called, let "cause_abort" take the part of
+ // "force_abort" (as done by cause_errthrow()).
cause_abort = force_abort;
force_abort = FALSE;
}
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 62a4d48645..79c36576d5 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2625,8 +2625,8 @@ static void realloc_cmdbuff(int len)
char_u *p = ccline.cmdbuff;
alloc_cmdbuff(len); // will get some more
- /* There isn't always a NUL after the command, but it may need to be
- * there, thus copy up to the NUL and add a NUL. */
+ // There isn't always a NUL after the command, but it may need to be
+ // there, thus copy up to the NUL and add a NUL.
memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen);
ccline.cmdbuff[ccline.cmdlen] = NUL;
xfree(p);
@@ -3427,24 +3427,24 @@ static bool cmdline_paste(int regname, bool literally, bool remcr)
bool allocated;
struct cmdline_info save_ccline;
- /* check for valid regname; also accept special characters for CTRL-R in
- * the command line */
+ // check for valid regname; also accept special characters for CTRL-R in
+ // the command line
if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W
&& regname != Ctrl_A && regname != Ctrl_L
&& !valid_yank_reg(regname, false)) {
return FAIL;
}
- /* A register containing CTRL-R can cause an endless loop. Allow using
- * CTRL-C to break the loop. */
+ // A register containing CTRL-R can cause an endless loop. Allow using
+ // CTRL-C to break the loop.
line_breakcheck();
if (got_int) {
return FAIL;
}
- /* Need to save and restore ccline. And set "textlock" to avoid nasty
- * things like going to another buffer when evaluating an expression. */
+ // Need to save and restore ccline. And set "textlock" to avoid nasty
+ // things like going to another buffer when evaluating an expression.
save_cmdline(&save_ccline);
textlock++;
const bool i = get_spec_reg(regname, &arg, &allocated, true);
@@ -6411,8 +6411,8 @@ static int open_cmdwin(void)
}
}
- /* Replace the empty last line with the current command-line and put the
- * cursor there. */
+ // Replace the empty last line with the current command-line and put the
+ // cursor there.
ml_replace(curbuf->b_ml.ml_line_count, ccline.cmdbuff, true);
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
curwin->w_cursor.col = ccline.cmdpos;
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index dc73e34111..05d1d69f9d 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -83,8 +83,7 @@ uint64_t extmark_set(buf_T *buf, uint64_t ns_id, uint64_t *idp, int row, colnr_T
ExtmarkItem it = map_del(uint64_t, ExtmarkItem)(buf->b_extmark_index,
old_mark);
if (it.decor) {
- decor_redraw(buf, row, row, it.decor);
- decor_free(it.decor);
+ decor_remove(buf, row, row, it.decor);
}
mark = marktree_revise(buf->b_marktree, itr);
goto revised;
@@ -96,12 +95,20 @@ uint64_t extmark_set(buf_T *buf, uint64_t ns_id, uint64_t *idp, int row, colnr_T
}
}
+ uint8_t decor_level = kDecorLevelNone; // no decor
+ if (decor) {
+ decor_level = kDecorLevelVisible; // decor affects redraw
+ if (kv_size(decor->virt_lines)) {
+ decor_level = kDecorLevelVirtLine; // decor affects horizontal size
+ }
+ }
+
if (end_row > -1) {
mark = marktree_put_pair(buf->b_marktree,
row, col, right_gravity,
- end_row, end_col, end_right_gravity);
+ end_row, end_col, end_right_gravity, decor_level);
} else {
- mark = marktree_put(buf->b_marktree, row, col, right_gravity);
+ mark = marktree_put(buf->b_marktree, row, col, right_gravity, decor_level);
}
revised:
@@ -117,6 +124,9 @@ revised:
}
if (decor) {
+ if (kv_size(decor->virt_lines)) {
+ buf->b_virt_line_blocks++;
+ }
decor_redraw(buf, row, end_row > -1 ? end_row : row, decor);
}
@@ -170,12 +180,7 @@ bool extmark_del(buf_T *buf, uint64_t ns_id, uint64_t id)
}
if (item.decor) {
- decor_redraw(buf, pos.row, pos2.row, item.decor);
- decor_free(item.decor);
- }
-
- if (mark == buf->b_virt_line_mark) {
- clear_virt_lines(buf, pos.row);
+ decor_remove(buf, pos.row, pos2.row, item.decor);
}
map_del(uint64_t, uint64_t)(ns->map, id);
@@ -228,17 +233,13 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id, int l_row, colnr_T l_col, int u_r
marktree_del_itr(buf->b_marktree, itr, false);
if (*del_status >= 0) { // we had a decor_id
DecorItem it = kv_A(decors, *del_status);
- decor_redraw(buf, it.row1, mark.row, it.decor);
- decor_free(it.decor);
+ decor_remove(buf, it.row1, mark.row, it.decor);
}
map_del(uint64_t, ssize_t)(&delete_set, mark.id);
continue;
}
uint64_t start_id = mark.id & ~MARKTREE_END_FLAG;
- if (start_id == buf->b_virt_line_mark) {
- clear_virt_lines(buf, mark.row);
- }
ExtmarkItem item = map_get(uint64_t, ExtmarkItem)(buf->b_extmark_index,
start_id);
@@ -257,8 +258,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id, int l_row, colnr_T l_col, int u_r
}
map_put(uint64_t, ssize_t)(&delete_set, other, decor_id);
} else if (item.decor) {
- decor_redraw(buf, mark.row, mark.row, item.decor);
- decor_free(item.decor);
+ decor_remove(buf, mark.row, mark.row, item.decor);
}
ExtmarkNs *my_ns = all_ns ? buf_ns_ref(buf, item.ns_id, false) : ns;
map_del(uint64_t, uint64_t)(my_ns->map, item.mark_id);
@@ -276,8 +276,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id, int l_row, colnr_T l_col, int u_r
marktree_del_itr(buf->b_marktree, itr, false);
if (decor_id >= 0) {
DecorItem it = kv_A(decors, decor_id);
- decor_redraw(buf, it.row1, pos.row, it.decor);
- decor_free(it.decor);
+ decor_remove(buf, it.row1, pos.row, it.decor);
}
});
map_clear(uint64_t, ssize_t)(&delete_set);
@@ -508,7 +507,6 @@ void extmark_apply_undo(ExtmarkUndoObject undo_info, bool undo)
kExtmarkNoUndo);
}
}
- curbuf->b_virt_line_pos = -1;
}
@@ -588,7 +586,6 @@ void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t
colnr_T new_col, bcount_t new_byte, ExtmarkOp undo)
{
buf->deleted_bytes2 = 0;
- buf->b_virt_line_pos = -1;
buf_updates_send_splice(buf, start_row, start_col, start_byte,
old_row, old_col, old_byte,
new_row, new_col, new_byte);
@@ -680,7 +677,6 @@ void extmark_move_region(buf_T *buf, int start_row, colnr_T start_col, bcount_t
colnr_T new_col, bcount_t new_byte, ExtmarkOp undo)
{
buf->deleted_bytes2 = 0;
- buf->b_virt_line_pos = -1;
// TODO(bfredl): this is not synced to the buffer state inside the callback.
// But unless we make the undo implementation smarter, this is not ensured
// anyway.
diff --git a/src/nvim/extmark_defs.h b/src/nvim/extmark_defs.h
index c0a4f4014f..4d4d9aefb5 100644
--- a/src/nvim/extmark_defs.h
+++ b/src/nvim/extmark_defs.h
@@ -11,10 +11,6 @@ typedef struct {
int hl_id;
} VirtTextChunk;
-typedef kvec_t(VirtTextChunk) VirtText;
-#define VIRTTEXT_EMPTY ((VirtText)KV_INITIAL_VALUE)
-typedef kvec_t(VirtText) VirtLines;
-
typedef struct
{
@@ -38,4 +34,10 @@ typedef enum {
kExtmarkUndoNoRedo, // Operation should be undoable, but not redoable
} ExtmarkOp;
+typedef enum {
+ kDecorLevelNone = 0,
+ kDecorLevelVisible = 1,
+ kDecorLevelVirtLine = 2,
+} DecorLevel;
+
#endif // NVIM_EXTMARK_DEFS_H
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 4a33d74011..dfe264b08c 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -224,8 +224,8 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
bool keep_dest_enc = false; // don't retry when char doesn't fit
// in destination encoding
int bad_char_behavior = BAD_REPLACE;
- /* BAD_KEEP, BAD_DROP or character to
- * replace with */
+ // BAD_KEEP, BAD_DROP or character to
+ // replace with
char_u *tmpname = NULL; // name of 'charconvert' output file
int fio_flags = 0;
char_u *fenc; // fileencoding to use
@@ -280,8 +280,8 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
|| (sfname == curbuf->b_ffname);
using_b_fname = (fname == curbuf->b_fname) || (sfname == curbuf->b_fname);
- /* After reading a file the cursor line changes but we don't want to
- * display the line. */
+ // After reading a file the cursor line changes but we don't want to
+ // display the line.
ex_no_reprint = true;
// don't display the file info for another buffer now
@@ -454,9 +454,9 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
// been created by someone else, a ":w" will complain.
curbuf->b_flags |= BF_NEW;
- /* Create a swap file now, so that other Vims are warned
- * that we are editing this file. Don't do this for a
- * "nofile" or "nowrite" buffer type. */
+ // Create a swap file now, so that other Vims are warned
+ // that we are editing this file. Don't do this for a
+ // "nofile" or "nowrite" buffer type.
if (!bt_dontwrite(curbuf)) {
check_need_swap(newfile);
// SwapExists autocommand may mess things up
@@ -524,9 +524,9 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
curbuf->b_start_bomb = FALSE;
}
- /* Create a swap file now, so that other Vims are warned that we are
- * editing this file.
- * Don't do this for a "nofile" or "nowrite" buffer type. */
+ // Create a swap file now, so that other Vims are warned that we are
+ // editing this file.
+ // Don't do this for a "nofile" or "nowrite" buffer type.
if (!bt_dontwrite(curbuf)) {
check_need_swap(newfile);
if (!read_stdin
@@ -854,8 +854,8 @@ retry:
#ifdef HAVE_ICONV
did_iconv = false;
#endif
- /* Skip conversion when it's already done (retry for wrong
- * "fileformat"). */
+ // Skip conversion when it's already done (retry for wrong
+ // "fileformat").
if (tmpname == NULL) {
tmpname = readfile_charconvert(fname, fenc, &fd);
if (tmpname == NULL) {
@@ -876,17 +876,17 @@ retry:
&& iconv_fd == (iconv_t)-1
#endif
) {
- /* Conversion wanted but we can't.
- * Try the next conversion in 'fileencodings' */
+ // Conversion wanted but we can't.
+ // Try the next conversion in 'fileencodings'
advance_fenc = true;
goto retry;
}
}
}
- /* Set "can_retry" when it's possible to rewind the file and try with
- * another "fenc" value. It's FALSE when no other "fenc" to try, reading
- * stdin or fixed at a specific encoding. */
+ // Set "can_retry" when it's possible to rewind the file and try with
+ // another "fenc" value. It's FALSE when no other "fenc" to try, reading
+ // stdin or fixed at a specific encoding.
can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc && !read_fifo);
if (!skip_read) {
@@ -1014,9 +1014,9 @@ retry:
read_buf_col += n;
break;
} else {
- /* Append whole line and new-line. Change NL
- * to NUL to reverse the effect done below. */
- for (ni = 0; ni < n; ++ni) {
+ // Append whole line and new-line. Change NL
+ // to NUL to reverse the effect done below.
+ for (ni = 0; ni < n; ni++) {
if (p[ni] == NL) {
ptr[tlen++] = NUL;
} else {
@@ -1076,10 +1076,10 @@ retry:
*(ptr - conv_restlen) = NUL;
conv_restlen = 0;
} else {
- /* Replace the trailing bytes with the replacement
- * character if we were converting; if we weren't,
- * leave the UTF8 checking code to do it, as it
- * works slightly differently. */
+ // Replace the trailing bytes with the replacement
+ // character if we were converting; if we weren't,
+ // leave the UTF8 checking code to do it, as it
+ // works slightly differently.
if (bad_char_behavior != BAD_KEEP && (fio_flags != 0
#ifdef HAVE_ICONV
|| iconv_fd != (iconv_t)-1
@@ -1212,8 +1212,8 @@ retry:
}
if (from_size > 0) {
- /* Some remaining characters, keep them for the next
- * round. */
+ // Some remaining characters, keep them for the next
+ // round.
memmove(conv_rest, (char_u *)fromp, from_size);
conv_restlen = (int)from_size;
}
@@ -1752,11 +1752,11 @@ failed:
}
if (newfile || read_buffer) {
redraw_curbuf_later(NOT_VALID);
- /* After reading the text into the buffer the diff info needs to
- * be updated. */
+ // After reading the text into the buffer the diff info needs to
+ // be updated.
diff_invalidate(curbuf);
- /* All folds in the window are invalid now. Mark them for update
- * before triggering autocommands. */
+ // All folds in the window are invalid now. Mark them for update
+ // before triggering autocommands.
foldUpdateAll(curwin);
} else if (linecnt) { // appended at least one line
appended_lines_mark(from, linecnt);
@@ -2129,8 +2129,8 @@ static char_u *readfile_charconvert(char_u *fname, char_u *fenc, int *fdp)
}
if (errmsg != NULL) {
- /* Don't use emsg(), it breaks mappings, the retry with
- * another type of conversion might still work. */
+ // Don't use emsg(), it breaks mappings, the retry with
+ // another type of conversion might still work.
MSG(errmsg);
if (tmpname != NULL) {
os_remove((char *)tmpname); // delete converted file
@@ -3908,9 +3908,9 @@ static int check_mtime(buf_T *buf, FileInfo *file_info)
static bool time_differs(long t1, long t2) FUNC_ATTR_CONST
{
#if defined(__linux__) || defined(MSWIN)
- /* On a FAT filesystem, esp. under Linux, there are only 5 bits to store
- * the seconds. Since the roundoff is done when flushing the inode, the
- * time may change unexpectedly by one second!!! */
+ // On a FAT filesystem, esp. under Linux, there are only 5 bits to store
+ // the seconds. Since the roundoff is done when flushing the inode, the
+ // time may change unexpectedly by one second!!!
return t1 - t2 > 1 || t2 - t1 > 1;
#else
return t1 != t2;
@@ -4192,8 +4192,8 @@ static bool need_conversion(const char_u *fenc)
same_encoding = TRUE;
fenc_flags = 0;
} else {
- /* Ignore difference between "ansi" and "latin1", "ucs-4" and
- * "ucs-4be", etc. */
+ // Ignore difference between "ansi" and "latin1", "ucs-4" and
+ // "ucs-4be", etc.
enc_flags = get_fio_flags(p_enc);
fenc_flags = get_fio_flags(fenc);
same_encoding = (enc_flags != 0 && fenc_flags == enc_flags);
@@ -4203,8 +4203,8 @@ static bool need_conversion(const char_u *fenc)
return false;
}
- /* Encodings differ. However, conversion is not needed when 'enc' is any
- * Unicode encoding and the file is UTF-8. */
+ // Encodings differ. However, conversion is not needed when 'enc' is any
+ // Unicode encoding and the file is UTF-8.
return !(fenc_flags == FIO_UTF8);
}
@@ -4697,8 +4697,8 @@ int vim_rename(const char_u *from, const char_u *to)
(void)os_rename(tempname, from);
return -1;
}
- /* If it fails for one temp name it will most likely fail
- * for any temp name, give up. */
+ // If it fails for one temp name it will most likely fail
+ // for any temp name, give up.
return -1;
}
}
@@ -4954,8 +4954,8 @@ int buf_check_timestamp(buf_T *buf)
buf_store_file_info(buf, &file_info);
}
- /* Don't do anything for a directory. Might contain the file
- * explorer. */
+ // Don't do anything for a directory. Might contain the file
+ // explorer.
if (os_isdir(buf->b_fname)) {
} else if ((buf->b_p_ar >= 0 ? buf->b_p_ar : p_ar)
&& !bufIsChanged(buf) && file_info_ok) {
@@ -5217,8 +5217,8 @@ void buf_reload(buf_T *buf, int orig_mode)
// Invalidate diff info if necessary.
diff_invalidate(curbuf);
- /* Restore the topline and cursor position and check it (lines may
- * have been removed). */
+ // Restore the topline and cursor position and check it (lines may
+ // have been removed).
if (old_topline > curbuf->b_ml.ml_line_count) {
curwin->w_topline = curbuf->b_ml.ml_line_count;
} else {
@@ -5237,9 +5237,9 @@ void buf_reload(buf_T *buf, int orig_mode)
}
}
- /* If the mode didn't change and 'readonly' was set, keep the old
- * value; the user probably used the ":view" command. But don't
- * reset it, might have had a read error. */
+ // If the mode didn't change and 'readonly' was set, keep the old
+ // value; the user probably used the ":view" command. But don't
+ // reset it, might have had a read error.
if (orig_mode == curbuf->b_orig_mode) {
curbuf->b_p_ro |= old_ro;
}
@@ -5754,8 +5754,8 @@ long write_eintr(int fd, void *buf, size_t bufsize)
long ret = 0;
long wlen;
- /* Repeat the write() so long it didn't fail, other than being interrupted
- * by a signal. */
+ // Repeat the write() so long it didn't fail, other than being interrupted
+ // by a signal.
while (ret < (long)bufsize) {
wlen = write(fd, (char *)buf + ret, bufsize - ret);
if (wlen < 0) {
diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h
index 9bfec44ef3..186d0b90ab 100644
--- a/src/nvim/fileio.h
+++ b/src/nvim/fileio.h
@@ -13,6 +13,7 @@
#define READ_DUMMY 0x10 // reading into a dummy buffer
#define READ_KEEP_UNDO 0x20 // keep undo info
#define READ_FIFO 0x40 // read from fifo or socket
+#define READ_NOWINENTER 0x80 // do not trigger BufWinEnter
#define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index e141f9bb62..8d86dca4d8 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -72,12 +72,12 @@ typedef struct {
linenr_T lnum_save; // line nr used by foldUpdateIEMSRecurse()
int lvl; // current level (-1 for undefined)
int lvl_next; // level used for next line
- int start; /* number of folds that are forced to start at
- this line. */
- int end; /* level of fold that is forced to end below
- this line */
- int had_end; /* level of fold that is forced to end above
- this line (copy of "end" of prev. line) */
+ int start; // number of folds that are forced to start at
+ // this line.
+ int end; // level of fold that is forced to end below
+ // this line
+ int had_end; // level of fold that is forced to end above
+ // this line (copy of "end" of prev. line)
} fline_T;
// Flag is set when redrawing is needed.
@@ -405,8 +405,8 @@ void opFoldRange(pos_T firstpos, pos_T lastpos, int opening, int recurse, int ha
for (lnum = first; lnum <= last; lnum = lnum_next + 1) {
pos_T temp = { lnum, 0, 0 };
lnum_next = lnum;
- /* Opening one level only: next fold to open is after the one going to
- * be opened. */
+ // Opening one level only: next fold to open is after the one going to
+ // be opened.
if (opening && !recurse) {
(void)hasFolding(lnum, NULL, &lnum_next);
}
@@ -639,8 +639,8 @@ void foldCreate(win_T *wp, pos_T start, pos_T end)
}
if (cont > 0) {
ga_grow(&fold_ga, cont);
- /* If the first fold starts before the new fold, let the new fold
- * start there. Otherwise the existing fold would change. */
+ // If the first fold starts before the new fold, let the new fold
+ // start there. Otherwise the existing fold would change.
if (start_rel.lnum > fp->fd_top) {
start_rel.lnum = fp->fd_top;
}
@@ -655,8 +655,8 @@ void foldCreate(win_T *wp, pos_T start, pos_T end)
fold_ga.ga_len += cont;
i += cont;
- /* Adjust line numbers in contained folds to be relative to the
- * new fold. */
+ // Adjust line numbers in contained folds to be relative to the
+ // new fold.
for (int j = 0; j < cont; j++) {
((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel.lnum;
}
@@ -673,9 +673,8 @@ void foldCreate(win_T *wp, pos_T start, pos_T end)
fp->fd_top = start_rel.lnum;
fp->fd_len = end_rel.lnum - start_rel.lnum + 1;
- /* We want the new fold to be closed. If it would remain open because
- * of using 'foldlevel', need to adjust fd_flags of containing folds.
- */
+ // We want the new fold to be closed. If it would remain open because
+ // of using 'foldlevel', need to adjust fd_flags of containing folds.
if (use_level && !closed && level < wp->w_p_fdl) {
closeFold(start, 1L);
}
@@ -916,8 +915,8 @@ int foldMoveTo(const bool updown, const int dir, const long count)
break;
}
}
- /* don't look for contained folds, they will always move
- * the cursor too far. */
+ // don't look for contained folds, they will always move
+ // the cursor too far.
last = true;
}
@@ -953,8 +952,8 @@ int foldMoveTo(const bool updown, const int dir, const long count)
}
}
} else {
- /* Open fold found, set cursor to its start/end and then check
- * nested folds. */
+ // Open fold found, set cursor to its start/end and then check
+ // nested folds.
if (dir == FORWARD) {
lnum = fp->fd_top + lnum_off + fp->fd_len - 1;
if (lnum > curwin->w_cursor.lnum) {
@@ -1375,8 +1374,8 @@ static void deleteFoldEntry(win_T *const wp, garray_T *const gap, const int idx,
memmove(fp, fp + 1, sizeof(*fp) * (size_t)(gap->ga_len - idx));
}
} else {
- /* Move nested folds one level up, to overwrite the fold that is
- * deleted. */
+ // Move nested folds one level up, to overwrite the fold that is
+ // deleted.
int moved = fp->fd_nested.ga_len;
ga_grow(gap, moved - 1);
{
@@ -1517,8 +1516,8 @@ static void foldMarkAdjustRecurse(win_T *wp, garray_T *gap, linenr_T line1, line
fp->fd_len += amount_after;
}
} else {
- /* 5. fold is below line1 and contains line2; need to
- * correct nested folds too */
+ // 5. fold is below line1 and contains line2; need to
+ // correct nested folds too
if (amount == MAXLNUM) {
foldMarkAdjustRecurse(wp, &fp->fd_nested, line1 - fp->fd_top,
line2 - fp->fd_top, amount,
@@ -1660,8 +1659,8 @@ static void foldCreateMarkers(win_T *wp, pos_T start, pos_T end)
foldAddMarker(buf, start, wp->w_p_fmr, foldstartmarkerlen);
foldAddMarker(buf, end, foldendmarker, foldendmarkerlen);
- /* Update both changes here, to avoid all folds after the start are
- * changed when the start marker is inserted and the end isn't. */
+ // Update both changes here, to avoid all folds after the start are
+ // changed when the start marker is inserted and the end isn't.
// TODO(teto): pass the buffer
changed_lines(start.lnum, (colnr_T)0, end.lnum, 0L, false);
@@ -1857,8 +1856,8 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
}
if (text != NULL) {
- /* Replace unprintable characters, if there are any. But
- * replace a TAB with a space. */
+ // Replace unprintable characters, if there are any. But
+ // replace a TAB with a space.
for (p = text; *p != NUL; p++) {
int len = utfc_ptr2len(p);
@@ -1941,10 +1940,9 @@ void foldtext_cleanup(char_u *str)
++len;
}
- /* May remove 'commentstring' start. Useful when it's a double
- * quote and we already removed a double quote. */
- for (p = s; p > str && ascii_iswhite(p[-1]); --p) {
- ;
+ // May remove 'commentstring' start. Useful when it's a double
+ // quote and we already removed a double quote.
+ for (p = s; p > str && ascii_iswhite(p[-1]); p--) {
}
if (p >= str + cms_slen
&& STRNCMP(p - cms_slen, cms_start, cms_slen) == 0) {
@@ -2074,12 +2072,12 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
getlevel = foldlevelIndent;
}
- /* Backup to a line for which the fold level is defined. Since it's
- * always defined for line one, we will stop there. */
+ // Backup to a line for which the fold level is defined. Since it's
+ // always defined for line one, we will stop there.
fline.lvl = -1;
- for (; !got_int; --fline.lnum) {
- /* Reset lvl_next each time, because it will be set to a value for
- * the next line, but we search backwards here. */
+ for (; !got_int; fline.lnum--) {
+ // Reset lvl_next each time, because it will be set to a value for
+ // the next line, but we search backwards here.
fline.lvl_next = -1;
getlevel(&fline);
if (fline.lvl >= 0) {
@@ -2128,15 +2126,15 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
end = start;
}
while (!got_int) {
- /* Always stop at the end of the file ("end" can be past the end of
- * the file). */
+ // Always stop at the end of the file ("end" can be past the end of
+ // the file).
if (fline.lnum > wp->w_buffer->b_ml.ml_line_count) {
break;
}
if (fline.lnum > end) {
- /* For "marker", "expr" and "syntax" methods: If a change caused
- * a fold to be removed, we need to continue at least until where
- * it ended. */
+ // For "marker", "expr" and "syntax" methods: If a change caused
+ // a fold to be removed, we need to continue at least until where
+ // it ended.
if (getlevel != foldlevelMarker
&& getlevel != foldlevelSyntax
&& getlevel != foldlevelExpr) {
@@ -2334,17 +2332,17 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
* firstlnum.
*/
while (!got_int) {
- /* set concat to 1 if it's allowed to concatenated this fold
- * with a previous one that touches it. */
+ // set concat to 1 if it's allowed to concatenated this fold
+ // with a previous one that touches it.
if (flp->start != 0 || flp->had_end <= MAX_LEVEL) {
concat = 0;
} else {
concat = 1;
}
- /* Find an existing fold to re-use. Preferably one that
- * includes startlnum, otherwise one that ends just before
- * startlnum or starts after it. */
+ // Find an existing fold to re-use. Preferably one that
+ // includes startlnum, otherwise one that ends just before
+ // startlnum or starts after it.
if (gap->ga_len > 0
&& (foldFind(gap, startlnum, &fp)
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len
@@ -2405,9 +2403,9 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
i = (int)(fp - (fold_T *)gap->ga_data);
foldSplit(flp->wp->w_buffer, gap, i, breakstart, breakend - 1);
fp = (fold_T *)gap->ga_data + i + 1;
- /* If using the "marker" or "syntax" method, we
- * need to continue until the end of the fold is
- * found. */
+ // If using the "marker" or "syntax" method, we
+ // need to continue until the end of the fold is
+ // found.
if (getlevel == foldlevelMarker
|| getlevel == foldlevelExpr
|| getlevel == foldlevelSyntax) {
@@ -2433,8 +2431,8 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
deleteFoldEntry(flp->wp, gap,
(int)(fp - (fold_T *)gap->ga_data), true);
} else {
- /* A fold has some lines above startlnum, truncate it
- * to stop just above startlnum. */
+ // A fold has some lines above startlnum, truncate it
+ // to stop just above startlnum.
fp->fd_len = startlnum - fp->fd_top;
foldMarkAdjustRecurse(flp->wp, &fp->fd_nested,
fp->fd_len, (linenr_T)MAXLNUM,
@@ -2442,8 +2440,8 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
fold_changed = true;
}
} else {
- /* Insert new fold. Careful: ga_data may be NULL and it
- * may change! */
+ // Insert new fold. Careful: ga_data may be NULL and it
+ // may change!
if (gap->ga_len == 0) {
i = 0;
} else {
@@ -2451,13 +2449,13 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
}
foldInsert(gap, i);
fp = (fold_T *)gap->ga_data + i;
- /* The new fold continues until bot, unless we find the
- * end earlier. */
+ // The new fold continues until bot, unless we find the
+ // end earlier.
fp->fd_top = firstlnum;
fp->fd_len = bot - firstlnum + 1;
- /* When the containing fold is open, the new fold is open.
- * The new fold is closed if the fold above it is closed.
- * The first fold depends on the containing fold. */
+ // When the containing fold is open, the new fold is open.
+ // The new fold is closed if the fold above it is closed.
+ // The first fold depends on the containing fold.
if (topflags == FD_OPEN) {
flp->wp->w_fold_manual = true;
fp->fd_flags = FD_OPEN;
@@ -2684,8 +2682,8 @@ static void foldSplit(buf_T *buf, garray_T *const gap, const int i, const linenr
fp[1].fd_small = kNone;
fp->fd_small = kNone;
- /* Move nested folds below bot to new fold. There can't be
- * any between top and bot, they have been removed by the caller. */
+ // Move nested folds below bot to new fold. There can't be
+ // any between top and bot, they have been removed by the caller.
garray_T *const gap1 = &fp->fd_nested;
garray_T *const gap2 = &fp[1].fd_nested;
if (foldFind(gap1, bot + 1 - fp->fd_top, &fp2)) {
@@ -3039,8 +3037,8 @@ static void foldlevelExpr(fline_T *flp)
flp->lvl = 0;
}
- /* KeyTyped may be reset to 0 when calling a function which invokes
- * do_cmdline(). To make 'foldopen' work correctly restore KeyTyped. */
+ // KeyTyped may be reset to 0 when calling a function which invokes
+ // do_cmdline(). To make 'foldopen' work correctly restore KeyTyped.
const bool save_keytyped = KeyTyped;
const int n = eval_foldexpr(flp->wp->w_p_fde, &c);
KeyTyped = save_keytyped;
@@ -3308,9 +3306,9 @@ static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off
}
}
} else {
- /* Open or close the leaf according to the window foldlevel.
- * Do not close a leaf that is already closed, as it will close
- * the parent. */
+ // Open or close the leaf according to the window foldlevel.
+ // Do not close a leaf that is already closed, as it will close
+ // the parent.
level = foldLevelWin(wp, off + fp->fd_top);
if ((fp->fd_flags == FD_CLOSED && wp->w_p_fdl >= level)
|| (fp->fd_flags != FD_CLOSED && wp->w_p_fdl < level)) {
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index eb836b9005..f8cf630411 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -144,10 +144,9 @@ static int KeyNoremap = 0; // remapping flags
#define RM_SCRIPT 2 // tb_noremap: remap local script mappings
#define RM_ABBR 4 // tb_noremap: don't remap, do abbrev.
-/* typebuf.tb_buf has three parts: room in front (for result of mappings), the
- * middle for typeahead and room for new characters (which needs to be 3 *
- * MAXMAPLEN) for the Amiga).
- */
+// typebuf.tb_buf has three parts: room in front (for result of mappings), the
+// middle for typeahead and room for new characters (which needs to be 3 *
+// MAXMAPLEN) for the Amiga).
#define TYPELEN_INIT (5 * (MAXMAPLEN + 3))
static char_u typebuf_init[TYPELEN_INIT]; // initial typebuf.tb_buf
static char_u noremapbuf_init[TYPELEN_INIT]; // initial typebuf.tb_noremap
@@ -682,7 +681,7 @@ static int read_redo(bool init, bool old_redo)
if ((c = *p) == NUL) {
return c;
}
- // Reverse the conversion done by add_char_buff() */
+ // Reverse the conversion done by add_char_buff()
// For a multi-byte character get all the bytes and return the
// converted character.
if (c != K_SPECIAL || p[1] == KS_SPECIAL) {
@@ -966,9 +965,9 @@ int ins_typebuf(char_u *str, int noremap, int offset, bool nottyped, bool silent
(char_u)((--nrm >= 0) ? val : RM_YES);
}
- /* tb_maplen and tb_silent only remember the length of mapped and/or
- * silent mappings at the start of the buffer, assuming that a mapped
- * sequence doesn't result in typed characters. */
+ // tb_maplen and tb_silent only remember the length of mapped and/or
+ // silent mappings at the start of the buffer, assuming that a mapped
+ // sequence doesn't result in typed characters.
if (nottyped || typebuf.tb_maplen > offset) {
typebuf.tb_maplen += addlen;
}
@@ -1116,8 +1115,8 @@ void del_typebuf(int len, int offset)
}
}
- /* Reset the flag that text received from a client or from feedkeys()
- * was inserted in the typeahead buffer. */
+ // Reset the flag that text received from a client or from feedkeys()
+ // was inserted in the typeahead buffer.
typebuf_was_filled = false;
if (++typebuf.tb_change_cnt == 0) {
typebuf.tb_change_cnt = 1;
@@ -1167,9 +1166,9 @@ static void gotchars(const char_u *chars, size_t len)
// output "debug mode" message next time in debug mode
debug_did_msg = false;
- /* Since characters have been typed, consider the following to be in
- * another mapping. Search string will be kept in history. */
- ++maptick;
+ // Since characters have been typed, consider the following to be in
+ // another mapping. Search string will be kept in history.
+ maptick++;
}
/*
@@ -1823,8 +1822,8 @@ static int vgetorpeek(bool advance)
flush_buffers(FLUSH_INPUT); // flush all typeahead
if (advance) {
- /* Also record this character, it might be needed to
- * get out of Insert mode. */
+ // Also record this character, it might be needed to
+ // get out of Insert mode.
*typebuf.tb_buf = (char_u)c;
gotchars(typebuf.tb_buf, 1);
}
@@ -2311,13 +2310,13 @@ static int vgetorpeek(bool advance)
/*
* get a character: 3. from the user - update display
*/
- /* In insert mode a screen update is skipped when characters
- * are still available. But when those available characters
- * are part of a mapping, and we are going to do a blocking
- * wait here. Need to update the screen to display the
- * changed text so far. Also for when 'lazyredraw' is set and
- * redrawing was postponed because there was something in the
- * input buffer (e.g., termresponse). */
+ // In insert mode a screen update is skipped when characters
+ // are still available. But when those available characters
+ // are part of a mapping, and we are going to do a blocking
+ // wait here. Need to update the screen to display the
+ // changed text so far. Also for when 'lazyredraw' is set and
+ // redrawing was postponed because there was something in the
+ // input buffer (e.g., termresponse).
if (((State & INSERT) != 0 || p_lz) && (State & CMDLINE) == 0
&& advance && must_redraw != 0 && !need_wait_return) {
update_screen(0);
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index 0b828777f4..d9830de2b5 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -794,8 +794,8 @@ void ex_hardcopy(exarg_T *eap)
break; // reached the end
}
} else if (prtpos.ff) {
- /* Line had a formfeed in it - start new page but
- * stay on the current line */
+ // Line had a formfeed in it - start new page but
+ // stay on the current line
break;
}
}
@@ -1505,9 +1505,8 @@ static void prt_flush_buffer(void)
prt_write_real(b / 255.0, 3);
prt_write_string("bg\n");
}
- /* Draw underlines before the text as it makes it slightly easier to
- * find the starting point.
- */
+ // Draw underlines before the text as it makes it slightly easier to
+ // find the starting point.
if (prt_do_underline) {
if (prt_do_moveto) {
prt_write_real(prt_pos_x_moveto, 2);
@@ -1696,9 +1695,8 @@ static bool prt_next_dsc(struct prt_dsc_line_S *p_dsc_line)
return true;
}
-/* Improved hand crafted parser to get the type, title, and version number of a
- * PS resource file so the file details can be added to the DSC header comments.
- */
+/// Improved hand crafted parser to get the type, title, and version number of a
+/// PS resource file so the file details can be added to the DSC header comments.
static bool prt_open_resource(struct prt_ps_resource_S *resource)
FUNC_ATTR_NONNULL_ALL
{
@@ -1906,9 +1904,8 @@ static void prt_dsc_font_resource(char *resource, struct prt_ps_font_S *ps_font)
static void prt_dsc_requirements(int duplex, int tumble, int collate, int color, int num_copies)
{
- /* Only output the comment if we need to.
- * Note: tumble is ignored if we are not duplexing
- */
+ // Only output the comment if we need to.
+ // Note: tumble is ignored if we are not duplexing
if (!(duplex || collate || color || (num_copies > 1))) {
return;
}
@@ -1967,10 +1964,9 @@ void mch_print_cleanup(void)
if (prt_out_mbyte) {
int i;
- /* Free off all CID font names created, but first clear duplicate
- * pointers to the same string (when the same font is used for more than
- * one style).
- */
+ // Free off all CID font names created, but first clear duplicate
+ // pointers to the same string (when the same font is used for more than
+ // one style).
for (i = PRT_PS_FONT_ROMAN; i <= PRT_PS_FONT_BOLDOBLIQUE; i++) {
if (prt_ps_mb_font.ps_fontname[i] != NULL) {
xfree(prt_ps_mb_font.ps_fontname[i]);
@@ -2048,9 +2044,8 @@ static int prt_get_cpl(void)
{
if (prt_use_number()) {
prt_number_width = PRINT_NUMBER_WIDTH * prt_char_width;
- /* If we are outputting multi-byte characters then line numbers will be
- * printed with half width characters
- */
+ // If we are outputting multi-byte characters then line numbers will be
+ // printed with half width characters
if (prt_out_mbyte) {
prt_number_width /= 2;
}
@@ -2168,10 +2163,10 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
p_encoding = enc_skip(p_enc);
}
- /* Look for a multi-byte font that matches the encoding and character set.
- * Only look if multi-byte character set is defined, or using multi-byte
- * encoding other than Unicode. This is because a Unicode encoding does not
- * uniquely identify a CJK character set to use. */
+ // Look for a multi-byte font that matches the encoding and character set.
+ // Only look if multi-byte character set is defined, or using multi-byte
+ // encoding other than Unicode. This is because a Unicode encoding does not
+ // uniquely identify a CJK character set to use.
p_mbenc = NULL;
props = enc_canon_props(p_encoding);
if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE))) {
@@ -2526,28 +2521,26 @@ int mch_print_begin(prt_settings_T *psettings)
prt_dsc_textline("Orientation", "Portrait");
prt_dsc_atend("Pages");
prt_dsc_textline("PageOrder", "Ascend");
- /* The bbox does not change with orientation - it is always in the default
- * user coordinate system! We have to recalculate right and bottom
- * coordinates based on the font metrics for the bbox to be accurate. */
+ // The bbox does not change with orientation - it is always in the default
+ // user coordinate system! We have to recalculate right and bottom
+ // coordinates based on the font metrics for the bbox to be accurate.
prt_page_margins(prt_mediasize[prt_media].width,
prt_mediasize[prt_media].height,
&left, &right, &top, &bottom);
bbox[0] = (int)left;
if (prt_portrait) {
- /* In portrait printing the fixed point is the top left corner so we
- * derive the bbox from that point. We have the expected cpl chars
- * across the media and lpp lines down the media.
- */
+ // In portrait printing the fixed point is the top left corner so we
+ // derive the bbox from that point. We have the expected cpl chars
+ // across the media and lpp lines down the media.
bbox[1] = (int)(top - (psettings->lines_per_page + prt_header_height())
* prt_line_height);
bbox[2] = (int)(left + psettings->chars_per_line * prt_char_width
+ 0.5);
bbox[3] = (int)(top + 0.5);
} else {
- /* In landscape printing the fixed point is the bottom left corner so we
- * derive the bbox from that point. We have lpp chars across the media
- * and cpl lines up the media.
- */
+ // In landscape printing the fixed point is the bottom left corner so we
+ // derive the bbox from that point. We have lpp chars across the media
+ // and cpl lines up the media.
bbox[1] = (int)bottom;
bbox[2] = (int)(left + ((psettings->lines_per_page
+ prt_header_height()) * prt_line_height) + 0.5);
@@ -2597,11 +2590,10 @@ int mch_print_begin(prt_settings_T *psettings)
}
}
- /* Find an encoding to use for printing.
- * Check 'printencoding'. If not set or not found, then use 'encoding'. If
- * that cannot be found then default to "latin1".
- * Note: VIM specific encoding header is always skipped.
- */
+ // Find an encoding to use for printing.
+ // Check 'printencoding'. If not set or not found, then use 'encoding'. If
+ // that cannot be found then default to "latin1".
+ // Note: VIM specific encoding header is always skipped.
if (!prt_out_mbyte) {
p_encoding = enc_skip(p_penc);
if (*p_encoding == NUL
@@ -2626,8 +2618,8 @@ int mch_print_begin(prt_settings_T *psettings)
if (!prt_open_resource(&res_encoding)) {
return FALSE;
}
- /* For the moment there are no checks on encoding resource files to
- * perform */
+ // For the moment there are no checks on encoding resource files to
+ // perform
} else {
p_encoding = enc_skip(p_penc);
if (*p_encoding == NUL) {
@@ -2643,8 +2635,8 @@ int mch_print_begin(prt_settings_T *psettings)
if (!prt_open_resource(&res_encoding)) {
return FALSE;
}
- /* For the moment there are no checks on encoding resource files to
- * perform */
+ // For the moment there are no checks on encoding resource files to
+ // perform
}
}
@@ -2742,8 +2734,8 @@ int mch_print_begin(prt_settings_T *psettings)
}
if (!prt_out_mbyte || prt_use_courier) {
- /* There will be only one Roman font encoding to be included in the PS
- * file. */
+ // There will be only one Roman font encoding to be included in the PS
+ // file.
if (!prt_add_resource(&res_encoding)) {
return FALSE;
}
@@ -2771,8 +2763,8 @@ int mch_print_begin(prt_settings_T *psettings)
// Font resource inclusion and definition
if (!prt_out_mbyte || prt_use_courier) {
- /* When using Courier for ASCII range when printing multi-byte, need to
- * pick up ASCII encoding to use with it. */
+ // When using Courier for ASCII range when printing multi-byte, need to
+ // pick up ASCII encoding to use with it.
if (prt_use_courier) {
p_encoding = (char_u *)prt_ascii_encoding;
}
@@ -2794,12 +2786,11 @@ int mch_print_begin(prt_settings_T *psettings)
prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
}
if (prt_out_mbyte) {
- /* Define the CID fonts to be used in the job. Typically CJKV fonts do
- * not have an italic form being a western style, so where no font is
- * defined for these faces VIM falls back to an existing face.
- * Note: if using Courier for the ASCII range then the printout will
- * have bold/italic/bolditalic regardless of the setting of printmbfont.
- */
+ // Define the CID fonts to be used in the job. Typically CJKV fonts do
+ // not have an italic form being a western style, so where no font is
+ // defined for these faces VIM falls back to an existing face.
+ // Note: if using Courier for the ASCII range then the printout will
+ // have bold/italic/bolditalic regardless of the setting of printmbfont.
prt_dsc_resources("IncludeResource", "font",
prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]);
if (!prt_custom_cmap) {
@@ -2872,8 +2863,8 @@ void mch_print_end(prt_settings_T *psettings)
prt_dsc_noarg("EOF");
- /* Write CTRL-D to close serial communication link if used.
- * NOTHING MUST BE WRITTEN AFTER THIS! */
+ // Write CTRL-D to close serial communication link if used.
+ // NOTHING MUST BE WRITTEN AFTER THIS!
prt_write_file((char_u *)"\004");
if (!prt_file_error && psettings->outfile == NULL
@@ -2977,13 +2968,12 @@ int mch_print_text_out(char_u *const textp, size_t len)
char_u *tofree = NULL;
double char_width = prt_char_width;
- /* Ideally VIM would create a rearranged CID font to combine a Roman and
- * CJKV font to do what VIM is doing here - use a Roman font for characters
- * in the ASCII range, and the original CID font for everything else.
- * The problem is that GhostScript still (as of 8.13) does not support
- * rearranged fonts even though they have been documented by Adobe for 7
- * years! If they ever do, a lot of this code will disappear.
- */
+ // Ideally VIM would create a rearranged CID font to combine a Roman and
+ // CJKV font to do what VIM is doing here - use a Roman font for characters
+ // in the ASCII range, and the original CID font for everything else.
+ // The problem is that GhostScript still (as of 8.13) does not support
+ // rearranged fonts even though they have been documented by Adobe for 7
+ // years! If they ever do, a lot of this code will disappear.
if (prt_use_courier) {
const bool in_ascii = (len == 1 && *p < 0x80);
if (prt_in_ascii) {
@@ -3020,9 +3010,8 @@ int mch_print_text_out(char_u *const textp, size_t len)
}
}
- /* Output any required changes to the graphics state, after flushing any
- * text buffered so far.
- */
+ // Output any required changes to the graphics state, after flushing any
+ // text buffered so far.
if (prt_attribute_change) {
prt_flush_buffer();
// Reset count of number of chars that will be printed
@@ -3100,16 +3089,14 @@ int mch_print_text_out(char_u *const textp, size_t len)
p++;
}
} else {
- /* Add next character to buffer of characters to output.
- * Note: One printed character may require several PS characters to
- * represent it, but we only count them as one printed character.
- */
+ // Add next character to buffer of characters to output.
+ // Note: One printed character may require several PS characters to
+ // represent it, but we only count them as one printed character.
ch = *p;
if (ch < 32 || ch == '(' || ch == ')' || ch == '\\') {
- /* Convert non-printing characters to either their escape or octal
- * sequence, ensures PS sent over a serial line does not interfere
- * with the comms protocol.
- */
+ // Convert non-printing characters to either their escape or octal
+ // sequence, ensures PS sent over a serial line does not interfere
+ // with the comms protocol.
ga_append(&prt_ps_buffer, '\\');
switch (ch) {
case BS:
diff --git a/src/nvim/lib/kvec.h b/src/nvim/lib/kvec.h
index eb2d9bbb77..ff0a8bcb7c 100644
--- a/src/nvim/lib/kvec.h
+++ b/src/nvim/lib/kvec.h
@@ -94,6 +94,17 @@
memcpy((v1).items, (v0).items, sizeof((v1).items[0]) * (v0).size); \
} while (0)
+#define kv_splice(v1, v0) \
+ do { \
+ if ((v1).capacity < (v1).size + (v0).size) { \
+ (v1).capacity = (v1).size + (v0).size; \
+ kv_roundup32((v1).capacity); \
+ kv_resize((v1), (v1).capacity); \
+ } \
+ memcpy((v1).items + (v1).size, (v0).items, sizeof((v1).items[0]) * (v0).size); \
+ (v1).size = (v1).size + (v0).size; \
+ } while (0)
+
#define kv_pushp(v) \
((((v).size == (v).capacity) ? (kv_resize_full(v), 0) : 0), \
((v).items + ((v).size++)))
@@ -101,6 +112,7 @@
#define kv_push(v, x) \
(*kv_pushp(v) = (x))
+
#define kv_a(v, i) \
(*(((v).capacity <= (size_t)(i) \
? ((v).capacity = (v).size = (i) + 1, \
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 00a43c9c79..4b4ab687b2 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -1461,9 +1461,9 @@ static void create_windows(mparm_T *parmp)
did_emsg = FALSE; // avoid hit-enter prompt
getout(1);
}
- /* We can't close the window, it would disturb what
- * happens next. Clear the file name and set the arg
- * index to -1 to delete it later. */
+ // We can't close the window, it would disturb what
+ // happens next. Clear the file name and set the arg
+ // index to -1 to delete it later.
setfname(curbuf, NULL, NULL, false);
curwin->w_arg_idx = -1;
swap_exists_action = SEA_NONE;
@@ -1553,8 +1553,8 @@ static void edit_buffers(mparm_T *parmp, char_u *cwd)
// happen when vimrc contains ":sall").
if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL) {
curwin->w_arg_idx = arg_idx;
- /* Edit file from arg list, if there is one. When "Quit" selected
- * at the ATTENTION prompt close the window. */
+ // Edit file from arg list, if there is one. When "Quit" selected
+ // at the ATTENTION prompt close the window.
swap_exists_did_quit = false;
(void)do_ecmd(0, arg_idx < GARGCOUNT
? alist_name(&GARGLIST[arg_idx]) : NULL,
diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c
index 39c1e36147..a7f540c748 100644
--- a/src/nvim/marktree.c
+++ b/src/nvim/marktree.c
@@ -221,9 +221,11 @@ static inline void marktree_putp_aux(MarkTree *b, mtnode_t *x, mtkey_t k)
}
}
-uint64_t marktree_put(MarkTree *b, int row, int col, bool right_gravity)
+uint64_t marktree_put(MarkTree *b, int row, int col, bool right_gravity, uint8_t decor_level)
{
uint64_t id = (b->next_id+=ID_INCR);
+ assert(decor_level < DECOR_LEVELS);
+ id = id | ((uint64_t)decor_level << DECOR_OFFSET);
uint64_t keyid = id;
if (right_gravity) {
// order all right gravity keys after the left ones, for effortless
@@ -235,9 +237,11 @@ uint64_t marktree_put(MarkTree *b, int row, int col, bool right_gravity)
}
uint64_t marktree_put_pair(MarkTree *b, int start_row, int start_col, bool start_right, int end_row,
- int end_col, bool end_right)
+ int end_col, bool end_right, uint8_t decor_level)
{
uint64_t id = (b->next_id+=ID_INCR)|PAIRED;
+ assert(decor_level < DECOR_LEVELS);
+ id = id | ((uint64_t)decor_level << DECOR_OFFSET);
uint64_t start_id = id|(start_right?RIGHT_GRAVITY:0);
uint64_t end_id = id|END_FLAG|(end_right?RIGHT_GRAVITY:0);
marktree_put_key(b, start_row, start_col, start_id);
diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h
index 02f73b8052..a1dcdf5164 100644
--- a/src/nvim/marktree.h
+++ b/src/nvim/marktree.h
@@ -75,4 +75,13 @@ typedef struct {
#define MARKTREE_PAIRED_FLAG (((uint64_t)1) << 1)
#define MARKTREE_END_FLAG (((uint64_t)1) << 0)
+#define DECOR_LEVELS 4
+#define DECOR_OFFSET 61
+#define DECOR_MASK (((uint64_t)(DECOR_LEVELS-1)) << DECOR_OFFSET)
+
+static inline uint8_t marktree_decor_level(uint64_t id)
+{
+ return (uint8_t)((id&DECOR_MASK) >> DECOR_OFFSET);
+}
+
#endif // NVIM_MARKTREE_H
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 62cc3b56ed..bd680330ca 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -675,16 +675,16 @@ static int utf_safe_read_char_adv(const char_u **s, size_t *n)
}
if (k <= *n) {
- /* We have a multibyte sequence and it isn't truncated by buffer
- * limits so utf_ptr2char() is safe to use. Or the first byte is
- * illegal (k=0), and it's also safe to use utf_ptr2char(). */
+ // We have a multibyte sequence and it isn't truncated by buffer
+ // limits so utf_ptr2char() is safe to use. Or the first byte is
+ // illegal (k=0), and it's also safe to use utf_ptr2char().
c = utf_ptr2char(*s);
- /* On failure, utf_ptr2char() returns the first byte, so here we
- * check equality with the first byte. The only non-ASCII character
- * which equals the first byte of its own UTF-8 representation is
- * U+00C3 (UTF-8: 0xC3 0x83), so need to check that special case too.
- * It's safe even if n=1, else we would have k=2 > n. */
+ // On failure, utf_ptr2char() returns the first byte, so here we
+ // check equality with the first byte. The only non-ASCII character
+ // which equals the first byte of its own UTF-8 representation is
+ // U+00C3 (UTF-8: 0xC3 0x83), so need to check that special case too.
+ // It's safe even if n=1, else we would have k=2 > n.
if (c != (int)(**s) || (c == 0xC3 && (*s)[1] == 0x83)) {
// byte sequence was successfully decoded
*s += k;
@@ -1582,8 +1582,8 @@ void show_utf8(void)
int clen;
int i;
- /* Get the byte length of the char under the cursor, including composing
- * characters. */
+ // Get the byte length of the char under the cursor, including composing
+ // characters.
line = get_cursor_pos_ptr();
len = utfc_ptr2len(line);
if (len == 0) {
@@ -1625,8 +1625,8 @@ int utf_head_off(const char_u *base, const char_u *p)
return 0;
}
- /* Skip backwards over trailing bytes: 10xx.xxxx
- * Skip backwards again if on a composing char. */
+ // Skip backwards over trailing bytes: 10xx.xxxx
+ // Skip backwards again if on a composing char.
const char_u *q;
for (q = p;; --q) {
// Move s to the last byte of this char.
@@ -1915,8 +1915,8 @@ void utf_find_illegal(void)
}
while (*p != NUL) {
- /* Illegal means that there are not enough trail bytes (checked by
- * utf_ptr2len()) or too many of them (overlong sequence). */
+ // Illegal means that there are not enough trail bytes (checked by
+ // utf_ptr2len()) or too many of them (overlong sequence).
len = utf_ptr2len(p);
if (*p >= 0x80 && (len == 1
|| utf_char2len(utf_ptr2char(p)) != len)) {
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 29e4a03d51..b4e9869b17 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -106,8 +106,8 @@ struct pointer_block {
uint16_t pb_id; // ID for pointer block: PTR_ID
uint16_t pb_count; // number of pointers in this block
uint16_t pb_count_max; // maximum value for pb_count
- PTR_EN pb_pointer[1]; /* list of pointers to blocks (actually longer)
- * followed by empty space until end of page */
+ PTR_EN pb_pointer[1]; // list of pointers to blocks (actually longer)
+ // followed by empty space until end of page
};
/*
@@ -1333,8 +1333,8 @@ int recover_names(char_u *fname, int list, int nr, char_u **fname_out)
if (dir_name[0] == '.' && dir_name[1] == NUL) { // check current dir
if (fname == NULL) {
names[0] = vim_strsave((char_u *)"*.sw?");
- /* For Unix names starting with a dot are special. MS-Windows
- * supports this too, on some file systems. */
+ // For Unix names starting with a dot are special. MS-Windows
+ // supports this too, on some file systems.
names[1] = vim_strsave((char_u *)".*.sw?");
names[2] = vim_strsave((char_u *)".sw?");
num_names = 3;
@@ -1343,11 +1343,11 @@ int recover_names(char_u *fname, int list, int nr, char_u **fname_out)
}
} else { // check directory dir_name
if (fname == NULL) {
- names[0] = (char_u *)concat_fnames((char *)dir_name, "*.sw?", TRUE);
- /* For Unix names starting with a dot are special. MS-Windows
- * supports this too, on some file systems. */
- names[1] = (char_u *)concat_fnames((char *)dir_name, ".*.sw?", TRUE);
- names[2] = (char_u *)concat_fnames((char *)dir_name, ".sw?", TRUE);
+ names[0] = (char_u *)concat_fnames((char *)dir_name, "*.sw?", true);
+ // For Unix names starting with a dot are special. MS-Windows
+ // supports this too, on some file systems.
+ names[1] = (char_u *)concat_fnames((char *)dir_name, ".*.sw?", true);
+ names[2] = (char_u *)concat_fnames((char *)dir_name, ".sw?", true);
num_names = 3;
} else {
int len = (int)STRLEN(dir_name);
@@ -3377,8 +3377,8 @@ static void attention_message(buf_T *buf, char_u *fname)
MSG_PUTS(_(" NEWER than swap file!\n"));
}
}
- /* Some of these messages are long to allow translation to
- * other languages. */
+ // Some of these messages are long to allow translation to
+ // other languages.
MSG_PUTS(_("\n(1) Another program may be editing the same file. If this is"
" the case,\n be careful not to end up with two different"
" instances of the same\n file when making changes."
@@ -3551,7 +3551,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
}
// give the ATTENTION message when there is an old swap file
- // for the current file, and the buffer was not recovered. */
+ // for the current file, and the buffer was not recovered.
if (differ == false && !(curbuf->b_flags & BF_RECOVERED)
&& vim_strchr(p_shm, SHM_ATTENTION) == NULL) {
int choice = 0;
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index 2250002f86..f1ae8740bb 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -305,8 +305,8 @@ static int add_menu_path(const char_u *const menu_path, vimmenu_T *menuarg,
parent = NULL;
name = path_name;
while (*name) {
- /* Get name of this element in the menu hierarchy, and the simplified
- * name (without mnemonic and accelerator text). */
+ // Get name of this element in the menu hierarchy, and the simplified
+ // name (without mnemonic and accelerator text).
next_name = menu_name_skip(name);
map_to = menutrans_lookup(name, (int)STRLEN(name));
if (map_to != NULL) {
@@ -481,8 +481,8 @@ erret:
xfree(path_name);
xfree(dname);
- /* Delete any empty submenu we added before discovering the error. Repeat
- * for higher levels. */
+ // Delete any empty submenu we added before discovering the error. Repeat
+ // for higher levels.
while (parent != NULL && parent->children == NULL) {
if (parent->parent == NULL) {
menup = root_menu_ptr;
@@ -650,8 +650,8 @@ static void free_menu(vimmenu_T **menup)
menu = *menup;
- /* Don't change *menup until after calling gui_mch_destroy_menu(). The
- * MacOS code needs the original structure to properly delete the menu. */
+ // Don't change *menup until after calling gui_mch_destroy_menu(). The
+ // MacOS code needs the original structure to properly delete the menu.
*menup = menu->next;
xfree(menu->name);
xfree(menu->dname);
@@ -1122,8 +1122,8 @@ char_u *get_menu_names(expand_T *xp, int idx)
should_advance = true;
}
}
- /* hack on menu separators: use a 'magic' char for the separator
- * so that '.' in names gets escaped properly */
+ // hack on menu separators: use a 'magic' char for the separator
+ // so that '.' in names gets escaped properly
STRCAT(tbuffer, "\001");
str = tbuffer;
} else {
@@ -1404,10 +1404,10 @@ static void execute_menu(const exarg_T *eap, vimmenu_T *menu)
mode = "Visual";
idx = MENU_INDEX_VISUAL;
- /* GEDDES: This is not perfect - but it is a
- * quick way of detecting whether we are doing this from a
- * selection - see if the range matches up with the visual
- * select start and end. */
+ // GEDDES: This is not perfect - but it is a
+ // quick way of detecting whether we are doing this from a
+ // selection - see if the range matches up with the visual
+ // select start and end.
if ((curbuf->b_visual.vi_start.lnum == eap->line1)
&& (curbuf->b_visual.vi_end.lnum) == eap->line2) {
// Set it up for visual mode - equivalent to gv.
@@ -1434,8 +1434,8 @@ static void execute_menu(const exarg_T *eap, vimmenu_T *menu)
check_cursor();
- /* Adjust the cursor to make sure it is in the correct pos
- * for exclusive mode */
+ // Adjust the cursor to make sure it is in the correct pos
+ // for exclusive mode
if (*p_sel == 'e' && gchar_cursor() != NUL) {
curwin->w_cursor.col++;
}
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 279f84f3d4..75f0dd6bb7 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -299,8 +299,8 @@ bool msg_attr_keep(char_u *s, int attr, bool keep, bool multiline)
}
++entered;
- /* Add message to history (unless it's a repeated kept message or a
- * truncated message) */
+ // Add message to history (unless it's a repeated kept message or a
+ // truncated message)
if (s != keep_msg
|| (*s != '<'
&& last_msg_hist != NULL
@@ -1089,8 +1089,8 @@ void wait_return(int redraw)
redraw_all_later(NOT_VALID);
}
- /* If using ":silent cmd", don't wait for a return. Also don't set
- * need_wait_return to do it later. */
+ // If using ":silent cmd", don't wait for a return. Also don't set
+ // need_wait_return to do it later.
if (msg_silent != 0) {
return;
}
@@ -1140,8 +1140,8 @@ void wait_return(int redraw)
hit_return_msg();
do {
- /* Remember "got_int", if it is set vgetc() probably returns a
- * CTRL-C, but we need to loop then. */
+ // Remember "got_int", if it is set vgetc() probably returns a
+ // CTRL-C, but we need to loop then.
had_got_int = got_int;
// Don't do mappings here, we put the character back in the
@@ -1213,8 +1213,8 @@ void wait_return(int redraw)
|| c == K_X1MOUSE || c == K_X2MOUSE) {
(void)jump_to_mouse(MOUSE_SETPOS, NULL, 0);
} else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C) {
- /* Put the character back in the typeahead buffer. Don't use the
- * stuff buffer, because lmaps wouldn't work. */
+ // Put the character back in the typeahead buffer. Don't use the
+ // stuff buffer, because lmaps wouldn't work.
ins_char_typebuf(c);
do_redraw = true; // need a redraw even though there is
// typeahead
@@ -1824,8 +1824,8 @@ void msg_prt_line(char_u *s, int list)
c_extra = NUL;
c_final = NUL;
c = *p_extra++;
- /* Use special coloring to be able to distinguish <hex> from
- * the same in plain text. */
+ // Use special coloring to be able to distinguish <hex> from
+ // the same in plain text.
attr = HL_ATTR(HLF_0);
} else if (c == ' ') {
if (lead != NULL && s <= lead) {
@@ -2155,8 +2155,8 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
}
}
- /* When we displayed a char in last column need to check if there
- * is still more. */
+ // When we displayed a char in last column need to check if there
+ // is still more.
if (did_last_char) {
continue;
}
@@ -2506,8 +2506,8 @@ void show_sb_text(void)
{
msgchunk_T *mp;
- /* Only show something if there is more than one line, otherwise it looks
- * weird, typing a command without output results in one line. */
+ // Only show something if there is more than one line, otherwise it looks
+ // weird, typing a command without output results in one line.
mp = msg_sb_start(last_msgchunk);
if (mp == NULL || mp->sb_prev == NULL) {
vim_beep(BO_MESS);
@@ -2578,8 +2578,8 @@ static void t_puts(int *t_col, const char_u *t_s, const char_u *s, int attr)
attr);
msg_col += *t_col;
*t_col = 0;
- /* If the string starts with a composing character don't increment the
- * column position for it. */
+ // If the string starts with a composing character don't increment the
+ // column position for it.
if (utf_iscomposing(utf_ptr2char(t_s))) {
msg_col--;
}
@@ -2747,8 +2747,8 @@ static int do_more_prompt(int typed_char)
case ':': // start new command line
if (!confirm_msg_used) {
- /* Since got_int is set all typeahead will be flushed, but we
- * want to keep this ':', remember that in a special way. */
+ // Since got_int is set all typeahead will be flushed, but we
+ // want to keep this ':', remember that in a special way.
typeahead_noflush(':');
cmdline_row = Rows - 1; // put ':' on this line
skip_redraw = true; // skip redraw once
@@ -2765,8 +2765,8 @@ static int do_more_prompt(int typed_char)
got_int = TRUE;
quit_more = TRUE;
}
- /* When there is some more output (wrapping line) display that
- * without another prompt. */
+ // When there is some more output (wrapping line) display that
+ // without another prompt.
lines_left = Rows - 1;
break;
@@ -2972,9 +2972,9 @@ void repeat_message(void)
ui_cursor_goto(msg_row, msg_col); // put cursor back
} else if (State == HITRETURN || State == SETWSIZE) {
if (msg_row == Rows - 1) {
- /* Avoid drawing the "hit-enter" prompt below the previous one,
- * overwrite it. Esp. useful when regaining focus and a
- * FocusGained autocmd exists but didn't draw anything. */
+ // Avoid drawing the "hit-enter" prompt below the previous one,
+ // overwrite it. Esp. useful when regaining focus and a
+ // FocusGained autocmd exists but didn't draw anything.
msg_didout = false;
msg_col = 0;
msg_clr_eos();
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 40db5b7cf3..ffc930ac1e 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -100,8 +100,8 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa
*/
found_one = FALSE;
for (list = curbuf->b_p_com; *list; ) {
- /* Get one option part into part_buf[]. Advance "list" to next
- * one. Put "string" at start of string. */
+ // Get one option part into part_buf[]. Advance "list" to next
+ // one. Put "string" at start of string.
if (!got_com && flags != NULL) {
*flags = list; // remember where flags started
}
@@ -113,16 +113,16 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa
}
*string++ = NUL; // isolate flags from string
- /* If we found a middle match previously, use that match when this
- * is not a middle or end. */
+ // If we found a middle match previously, use that match when this
+ // is not a middle or end.
if (middle_match_len != 0
&& vim_strchr(part_buf, COM_MIDDLE) == NULL
&& vim_strchr(part_buf, COM_END) == NULL) {
break;
}
- /* When we already found a nested comment, only accept further
- * nested comments. */
+ // When we already found a nested comment, only accept further
+ // nested comments.
if (got_com && vim_strchr(part_buf, COM_NEST) == NULL) {
continue;
}
@@ -132,10 +132,10 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa
continue;
}
- /* Line contents and string must match.
- * When string starts with white space, must have some white space
- * (but the amount does not need to match, there might be a mix of
- * TABs and spaces). */
+ // Line contents and string must match.
+ // When string starts with white space, must have some white space
+ // (but the amount does not need to match, there might be a mix of
+ // TABs and spaces).
if (ascii_iswhite(string[0])) {
if (i == 0 || !ascii_iswhite(line[i - 1])) {
continue; // missing white space
@@ -150,18 +150,18 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa
if (string[j] != NUL) {
continue; // string doesn't match
}
- /* When 'b' flag used, there must be white space or an
- * end-of-line after the string in the line. */
+ // When 'b' flag used, there must be white space or an
+ // end-of-line after the string in the line.
if (vim_strchr(part_buf, COM_BLANK) != NULL
&& !ascii_iswhite(line[i + j]) && line[i + j] != NUL) {
continue;
}
- /* We have found a match, stop searching unless this is a middle
- * comment. The middle comment can be a substring of the end
- * comment in which case it's better to return the length of the
- * end comment and its flags. Thus we keep searching with middle
- * and end matches and use an end match if it matches better. */
+ // We have found a match, stop searching unless this is a middle
+ // comment. The middle comment can be a substring of the end
+ // comment in which case it's better to return the length of the
+ // end comment and its flags. Thus we keep searching with middle
+ // and end matches and use an end match if it matches better.
if (vim_strchr(part_buf, COM_MIDDLE) != NULL) {
if (middle_match_len == 0) {
middle_match_len = j;
@@ -170,8 +170,8 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa
continue;
}
if (middle_match_len != 0 && j > middle_match_len) {
- /* Use this match instead of the middle match, since it's a
- * longer thus better match. */
+ // Use this match instead of the middle match, since it's a
+ // longer thus better match.
middle_match_len = 0;
}
@@ -183,8 +183,8 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa
}
if (middle_match_len != 0) {
- /* Use the previously found middle match after failing to find a
- * match with an end. */
+ // Use the previously found middle match after failing to find a
+ // match with an end.
if (!got_com && flags != NULL) {
*flags = saved_flags;
}
@@ -254,8 +254,8 @@ int get_last_leader_offset(char_u *line, char_u **flags)
*/
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
string = vim_strchr(part_buf, ':');
- if (string == NULL) { /* If everything is fine, this cannot actually
- * happen. */
+ if (string == NULL) { // If everything is fine, this cannot actually
+ // happen.
continue;
}
*string++ = NUL; // Isolate flags from string.
@@ -331,11 +331,10 @@ int get_last_leader_offset(char_u *line, char_u **flags)
lower_check_bound = i;
- /* Let's verify whether the comment leader found is a substring
- * of other comment leaders. If it is, let's adjust the
- * lower_check_bound so that we make sure that we have determined
- * the comment leader correctly.
- */
+ // Let's verify whether the comment leader found is a substring
+ // of other comment leaders. If it is, let's adjust the
+ // lower_check_bound so that we make sure that we have determined
+ // the comment leader correctly.
while (ascii_iswhite(*com_leader)) {
++com_leader;
@@ -359,8 +358,8 @@ int get_last_leader_offset(char_u *line, char_u **flags)
continue;
}
- /* Now we have to verify whether string ends with a substring
- * beginning the com_leader. */
+ // Now we have to verify whether string ends with a substring
+ // beginning the com_leader.
for (off = (len2 > i ? i : len2); off > 0 && off + len1 > len2; ) {
--off;
if (!STRNCMP(string + off, com_leader, len2 - off)) {
@@ -497,9 +496,9 @@ int get_keystroke(MultiQueue *events)
for (;; ) {
// flush output before waiting
ui_flush();
- /* Leave some room for check_termcode() to insert a key code into (max
- * 5 chars plus NUL). And fix_input_buffer() can triple the number of
- * bytes. */
+ // Leave some room for check_termcode() to insert a key code into (max
+ // 5 chars plus NUL). And fix_input_buffer() can triple the number of
+ // bytes.
maxlen = (buflen - 6 - len) / 3;
if (buf == NULL) {
buf = xmalloc((size_t)buflen);
@@ -511,8 +510,8 @@ int get_keystroke(MultiQueue *events)
maxlen = (buflen - 6 - len) / 3;
}
- /* First time: blocking wait. Second time: wait up to 100ms for a
- * terminal code to complete. */
+ // First time: blocking wait. Second time: wait up to 100ms for a
+ // terminal code to complete.
n = os_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0, events);
if (n > 0) {
// Replace zero and CSI by a special key code.
@@ -575,8 +574,8 @@ int get_number(int colon, int *mouse_used)
*mouse_used = FALSE;
}
- /* When not printing messages, the user won't know what to type, return a
- * zero (as if CR was hit). */
+ // When not printing messages, the user won't know what to type, return a
+ // zero (as if CR was hit).
if (msg_silent != 0) {
return 0;
}
@@ -674,9 +673,9 @@ void msgmore(long n)
return;
}
- /* We don't want to overwrite another important message, but do overwrite
- * a previous "more lines" or "fewer lines" message, so that "5dd" and
- * then "put" reports the last action. */
+ // We don't want to overwrite another important message, but do overwrite
+ // a previous "more lines" or "fewer lines" message, so that "5dd" and
+ // then "put" reports the last action.
if (keep_msg != NULL && !keep_msg_more) {
return;
}
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 64ba02064f..5114cd6d8a 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -226,9 +226,9 @@ void update_topline(win_T *wp)
n = wp->w_topline + *so_ptr - wp->w_cursor.lnum;
}
- /* If we weren't very close to begin with, we scroll to put the
- * cursor in the middle of the window. Otherwise put the cursor
- * near the top of the window. */
+ // If we weren't very close to begin with, we scroll to put the
+ // cursor in the middle of the window. Otherwise put the cursor
+ // near the top of the window.
if (n >= halfheight) {
scroll_cursor_halfway(false);
} else {
@@ -263,9 +263,9 @@ void update_topline(win_T *wp)
|| hasAnyFolding(wp))) {
lineoff_T loff;
- /* Cursor is (a few lines) above botline, check if there are
- * 'scrolloff' window lines below the cursor. If not, need to
- * scroll. */
+ // Cursor is (a few lines) above botline, check if there are
+ // 'scrolloff' window lines below the cursor. If not, need to
+ // scroll.
int n = wp->w_empty_rows;
loff.lnum = wp->w_cursor.lnum;
// In a fold go to its last line.
@@ -570,8 +570,8 @@ static void curs_rows(win_T *wp)
continue; // skip changed or deleted lines
}
if (wp->w_lines[i].wl_lnum == lnum) {
- /* Check for newly inserted lines below this row, in which
- * case we need to check for folded lines. */
+ // Check for newly inserted lines below this row, in which
+ // case we need to check for folded lines.
if (!wp->w_buffer->b_mod_set
|| wp->w_lines[i].wl_lastlnum < wp->w_cursor.lnum
|| wp->w_buffer->b_mod_top
@@ -815,8 +815,8 @@ void curs_columns(win_T *wp, int may_scroll)
if (off_left < 0 || off_right > 0) {
int diff = (off_left < 0) ? -off_left: off_right;
- /* When far off or not enough room on either side, put cursor in
- * middle of window. */
+ // When far off or not enough room on either side, put cursor in
+ // middle of window.
int new_leftcol;
if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left) {
new_leftcol = wp->w_wcol - extra - textwidth / 2;
@@ -848,8 +848,8 @@ void curs_columns(win_T *wp, int may_scroll)
wp->w_wcol = 0;
}
- /* Skip over filler lines. At the top use w_topfill, there
- * may be some filler lines above the window. */
+ // Skip over filler lines. At the top use w_topfill, there
+ // may be some filler lines above the window.
if (wp->w_cursor.lnum == wp->w_topline) {
wp->w_wrow += wp->w_topfill;
} else {
@@ -869,12 +869,12 @@ void curs_columns(win_T *wp, int may_scroll)
&& wp->w_cursor.lnum == wp->w_topline
&& width > 0
&& wp->w_width_inner != 0) {
- /* Cursor past end of screen. Happens with a single line that does
- * not fit on screen. Find a skipcol to show the text around the
- * cursor. Avoid scrolling all the time. compute value of "extra":
- * 1: Less than "p_so" lines above
- * 2: Less than "p_so" lines below
- * 3: both of them */
+ // Cursor past end of screen. Happens with a single line that does
+ // not fit on screen. Find a skipcol to show the text around the
+ // cursor. Avoid scrolling all the time. compute value of "extra":
+ // 1: Less than "p_so" lines above
+ // 2: Less than "p_so" lines below
+ // 3: both of them
extra = 0;
if (wp->w_skipcol + so * width > wp->w_virtcol) {
extra = 1;
@@ -1592,8 +1592,8 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
- curwin->w_filler_rows;
while (loff.lnum > 1) {
- /* Stop when scrolled nothing or at least "min_scroll", found "extra"
- * context for 'scrolloff' and counted all lines below the window. */
+ // Stop when scrolled nothing or at least "min_scroll", found "extra"
+ // context for 'scrolloff' and counted all lines below the window.
if ((((scrolled <= 0 || scrolled >= min_scroll)
&& extra >= (mouse_dragging > 0 ? mouse_dragging - 1 : so))
|| boff.lnum + 1 > curbuf->b_ml.ml_line_count)
@@ -1912,8 +1912,8 @@ int onepage(Direction dir, long count)
curwin->w_topfill = 0;
curwin->w_valid &= ~(VALID_WROW|VALID_CROW);
} else {
- /* For the overlap, start with the line just below the window
- * and go upwards. */
+ // For the overlap, start with the line just below the window
+ // and go upwards.
loff.lnum = curwin->w_botline;
loff.fill = win_get_fill(curwin, loff.lnum)
- curwin->w_filler_rows;
@@ -1948,9 +1948,9 @@ int onepage(Direction dir, long count)
continue;
}
- /* Find the line at the top of the window that is going to be the
- * line at the bottom of the window. Make sure this results in
- * the same line as before doing CTRL-F. */
+ // Find the line at the top of the window that is going to be the
+ // line at the bottom of the window. Make sure this results in
+ // the same line as before doing CTRL-F.
loff.lnum = curwin->w_topline - 1;
loff.fill = win_get_fill(curwin, loff.lnum + 1) - curwin->w_topfill;
get_scroll_overlap(&loff, 1);
@@ -1963,8 +1963,8 @@ int onepage(Direction dir, long count)
}
curwin->w_cursor.lnum = loff.lnum;
- /* Find the line just above the new topline to get the right line
- * at the bottom of the window. */
+ // Find the line just above the new topline to get the right line
+ // at the bottom of the window.
n = 0;
while (n <= curwin->w_height_inner && loff.lnum >= 1) {
topline_back(curwin, &loff);
@@ -1987,13 +1987,13 @@ int onepage(Direction dir, long count)
// We're at the wrong end of a fold now.
(void)hasFoldingWin(curwin, loff.lnum, &loff.lnum, NULL, true, NULL);
- /* Always scroll at least one line. Avoid getting stuck on
- * very long lines. */
+ // Always scroll at least one line. Avoid getting stuck on
+ // very long lines.
if (loff.lnum >= curwin->w_topline
&& (loff.lnum > curwin->w_topline
|| loff.fill >= curwin->w_topfill)) {
- /* First try using the maximum number of filler lines. If
- * that's not enough, backup one line. */
+ // First try using the maximum number of filler lines. If
+ // that's not enough, backup one line.
loff.fill = curwin->w_topfill;
if (curwin->w_topfill < win_get_fill(curwin, curwin->w_topline)) {
max_topfill();
@@ -2266,8 +2266,8 @@ void do_check_cursorbind(void)
curwin->w_curswant = curswant;
curwin->w_set_curswant = set_curswant;
- /* Make sure the cursor is in a valid position. Temporarily set
- * "restart_edit" to allow the cursor to be beyond the EOL. */
+ // Make sure the cursor is in a valid position. Temporarily set
+ // "restart_edit" to allow the cursor to be beyond the EOL.
{
int restart_edit_save = restart_edit;
restart_edit = true;
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 686071e25a..438ddd6fd3 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -414,14 +414,14 @@ static int find_command(int cmdchar)
return -1;
}
- /* We use the absolute value of the character. Special keys have a
- * negative value, but are sorted on their absolute value. */
+ // We use the absolute value of the character. Special keys have a
+ // negative value, but are sorted on their absolute value.
if (cmdchar < 0) {
cmdchar = -cmdchar;
}
- /* If the character is in the first part: The character is the index into
- * nv_cmd_idx[]. */
+ // If the character is in the first part: The character is the index into
+ // nv_cmd_idx[].
assert(nv_max_linear < (int)NV_CMDS_SIZE);
if (cmdchar <= nv_max_linear) {
return nv_cmd_idx[cmdchar];
@@ -3897,8 +3897,8 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
pat = xmalloc(len + 7);
- /* Put "\V" before the pattern to avoid that the special meaning of "."
- * and "~" causes trouble. */
+ // Put "\V" before the pattern to avoid that the special meaning of "."
+ // and "~" causes trouble.
assert(len <= INT_MAX);
sprintf((char *)pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s",
(int)len, ptr);
@@ -4252,9 +4252,9 @@ void scroll_redraw(int up, long count)
check_cursor_moved(curwin);
curwin->w_valid |= VALID_TOPLINE;
- /* If moved back to where we were, at least move the cursor, otherwise
- * we get stuck at one position. Don't move the cursor up if the
- * first line of the buffer is already on the screen */
+ // If moved back to where we were, at least move the cursor, otherwise
+ // we get stuck at one position. Don't move the cursor up if the
+ // first line of the buffer is already on the screen
while (curwin->w_topline == prev_topline
&& curwin->w_topfill == prev_topfill) {
if (up) {
@@ -4338,7 +4338,7 @@ static void nv_zet(cmdarg_T *cap)
dozet:
// "zf" and "zF" are always an operator, "zd", "zo", "zO", "zc"
// and "zC" only in Visual mode. "zj" and "zk" are motion
- // commands. */
+ // commands.
if (cap->nchar != 'f' && cap->nchar != 'F'
&& !(VIsual_active && vim_strchr((char_u *)"dcCoO", cap->nchar))
&& cap->nchar != 'j' && cap->nchar != 'k'
@@ -5003,9 +5003,9 @@ static void nv_ident(cmdarg_T *cap)
return;
}
- /* Allocate buffer to put the command in. Inserting backslashes can
- * double the length of the word. p_kp / curbuf->b_p_kp could be added
- * and some numbers. */
+ // Allocate buffer to put the command in. Inserting backslashes can
+ // double the length of the word. p_kp / curbuf->b_p_kp could be added
+ // and some numbers.
char_u *kp = *curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp; // 'keywordprg'
assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty.
bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command
@@ -5046,8 +5046,8 @@ static void nv_ident(cmdarg_T *cap)
STRCAT(buf, kp);
STRCAT(buf, " ");
} else {
- /* An external command will probably use an argument starting
- * with "-" as an option. To avoid trouble we skip the "-". */
+ // An external command will probably use an argument starting
+ // with "-" as an option. To avoid trouble we skip the "-".
while (*ptr == '-' && n > 0) {
++ptr;
--n;
@@ -5058,8 +5058,8 @@ static void nv_ident(cmdarg_T *cap)
return;
}
- /* When a count is given, turn it into a range. Is this
- * really what we want? */
+ // When a count is given, turn it into a range. Is this
+ // really what we want?
bool isman = (STRCMP(kp, "man") == 0);
bool isman_s = (STRCMP(kp, "man -s") == 0);
if (cap->count0 != 0 && !(isman || isman_s)) {
@@ -5141,8 +5141,8 @@ static void nv_ident(cmdarg_T *cap)
if (vim_strchr(aux_ptr, *ptr) != NULL) {
*p++ = '\\';
}
- /* When current byte is a part of multibyte character, copy all
- * bytes of that character. */
+ // When current byte is a part of multibyte character, copy all
+ // bytes of that character.
const size_t len = (size_t)(utfc_ptr2len(ptr) - 1);
for (size_t i = 0; i < len && n > 0; i++, n--) {
*p++ = *ptr++;
@@ -5415,10 +5415,9 @@ static void nv_left(cmdarg_T *cap)
cap->oap->inclusive = false;
for (n = cap->count1; n > 0; --n) {
if (oneleft() == false) {
- /* <BS> and <Del> wrap to previous line if 'whichwrap' has 'b'.
- * 'h' wraps to previous line if 'whichwrap' has 'h'.
- * CURS_LEFT wraps to previous line if 'whichwrap' has '<'.
- */
+ // <BS> and <Del> wrap to previous line if 'whichwrap' has 'b'.
+ // 'h' wraps to previous line if 'whichwrap' has 'h'.
+ // CURS_LEFT wraps to previous line if 'whichwrap' has '<'.
if ((((cap->cmdchar == K_BS || cap->cmdchar == Ctrl_H)
&& vim_strchr(p_ww, 'b') != NULL)
|| (cap->cmdchar == 'h' && vim_strchr(p_ww, 'h') != NULL)
@@ -5570,9 +5569,9 @@ static void nv_dollar(cmdarg_T *cap)
{
cap->oap->motion_type = kMTCharWise;
cap->oap->inclusive = true;
- /* In virtual mode when off the edge of a line and an operator
- * is pending (whew!) keep the cursor where it is.
- * Otherwise, send it to the end of the line. */
+ // In virtual mode when off the edge of a line and an operator
+ // is pending (whew!) keep the cursor where it is.
+ // Otherwise, send it to the end of the line.
if (!virtual_active() || gchar_cursor() != NUL
|| cap->oap->op_type == OP_NOP) {
curwin->w_curswant = MAXCOL; // so we stay at the end
@@ -6278,9 +6277,9 @@ static void nv_replace(cmdarg_T *cap)
ins_char(cap->ncharC2);
}
}
- --curwin->w_cursor.col; // cursor on the last replaced char
- /* if the character on the left of the current cursor is a multi-byte
- * character, move two characters left */
+ curwin->w_cursor.col--; // cursor on the last replaced char
+ // if the character on the left of the current cursor is a multi-byte
+ // character, move two characters left
mb_adjust_cursor();
curbuf->b_op_end = curwin->w_cursor;
curwin->w_set_curswant = true;
@@ -6802,8 +6801,8 @@ static void n_start_visual_mode(int c)
if (p_smd && msg_silent == 0) {
redraw_cmdline = true; // show visual mode later
}
- /* Only need to redraw this line, unless still need to redraw an old
- * Visual area (when 'lazyredraw' is set). */
+ // Only need to redraw this line, unless still need to redraw an old
+ // Visual area (when 'lazyredraw' is set).
if (curwin->w_redr_type < INVERTED) {
curwin->w_old_cursor_lnum = curwin->w_cursor.lnum;
curwin->w_old_visual_lnum = curwin->w_cursor.lnum;
@@ -7571,8 +7570,8 @@ static void nv_home(cmdarg_T *cap)
cap->count0 = 1;
nv_pipe(cap);
}
- ins_at_eol = false; /* Don't move cursor past eol (only necessary in a
- one-character line). */
+ ins_at_eol = false; // Don't move cursor past eol (only necessary in a
+ // one-character line).
}
/*
@@ -7589,8 +7588,8 @@ static void nv_pipe(cmdarg_T *cap)
} else {
curwin->w_curswant = 0;
}
- /* keep curswant at the column where we wanted to go, not where
- * we ended; differs if line is too short */
+ // keep curswant at the column where we wanted to go, not where
+ // we ended; differs if line is too short
curwin->w_set_curswant = false;
}
@@ -7661,8 +7660,8 @@ static void nv_wordcmd(cmdarg_T *cap)
n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP);
}
- /* Don't leave the cursor on the NUL past the end of line. Unless we
- * didn't move it forward. */
+ // Don't leave the cursor on the NUL past the end of line. Unless we
+ // didn't move it forward.
if (lt(startpos, curwin->w_cursor)) {
adjust_cursor(cap->oap);
}
@@ -7711,8 +7710,8 @@ static void nv_beginline(cmdarg_T *cap)
if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) {
foldOpenCursor();
}
- ins_at_eol = false; /* Don't move cursor past eol (only necessary in a
- one-character line). */
+ ins_at_eol = false; // Don't move cursor past eol (only necessary in a
+ // one-character line).
}
/*
@@ -7857,8 +7856,8 @@ static void nv_esc(cmdarg_T *cap)
}
}
- /* Don't reset "restart_edit" when 'insertmode' is set, it won't be
- * set again below when halfway through a mapping. */
+ // Don't reset "restart_edit" when 'insertmode' is set, it won't be
+ // set again below when halfway through a mapping.
if (!p_im) {
restart_edit = 0;
}
@@ -7885,8 +7884,8 @@ static void nv_esc(cmdarg_T *cap)
}
clearop(cap->oap);
- /* A CTRL-C is often used at the start of a menu. When 'insertmode' is
- * set return to Insert mode afterwards. */
+ // A CTRL-C is often used at the start of a menu. When 'insertmode' is
+ // set return to Insert mode afterwards.
if (restart_edit == 0 && goto_im()
&& ex_normal_busy == 0) {
restart_edit = 'a';
@@ -7940,8 +7939,8 @@ static void nv_edit(cmdarg_T *cap)
break;
case 'a': // "a"ppend is like "i"nsert on the next character.
- /* increment coladd when in virtual space, increment the
- * column otherwise, also to append after an unprintable char */
+ // increment coladd when in virtual space, increment the
+ // column otherwise, also to append after an unprintable char
if (virtual_active()
&& (curwin->w_cursor.coladd > 0
|| *get_cursor_pos_ptr() == NUL
@@ -8209,11 +8208,10 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent)
}
if (VIsual_active) {
- /* Putting in Visual mode: The put text replaces the selected
- * text. First delete the selected text, then put the new text.
- * Need to save and restore the registers that the delete
- * overwrites if the old contents is being put.
- */
+ // Putting in Visual mode: The put text replaces the selected
+ // text. First delete the selected text, then put the new text.
+ // Need to save and restore the registers that the delete
+ // overwrites if the old contents is being put.
was_visual = true;
regname = cap->oap->regname;
// '+' and '*' could be the same selection
@@ -8286,14 +8284,14 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent)
}
}
- /* When all lines were selected and deleted do_put() leaves an empty
- * line that needs to be deleted now. */
+ // When all lines were selected and deleted do_put() leaves an empty
+ // line that needs to be deleted now.
if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) {
ml_delete(curbuf->b_ml.ml_line_count, true);
deleted_lines(curbuf->b_ml.ml_line_count + 1, 1);
- /* If the cursor was in that line, move it to the end of the last
- * line. */
+ // If the cursor was in that line, move it to the end of the last
+ // line.
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
coladvance(MAXCOL);
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 3a8f7c42a5..eb37213f1a 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -391,8 +391,8 @@ static void shift_block(oparg_T *oap, int amount)
total += incr;
bd.start_vcol += incr;
}
- /* OK, now total=all the VWS reqd, and textstart points at the 1st
- * non-ws char in the block. */
+ // OK, now total=all the VWS reqd, and textstart points at the 1st
+ // non-ws char in the block.
if (!curbuf->b_p_et) {
tabstop_fromto(ws_vcol, ws_vcol + total, p_ts, p_vts, &i, &j);
} else {
@@ -459,14 +459,14 @@ static void shift_block(oparg_T *oap, int amount)
// The column to which we will shift the text.
destination_col = non_white_col - shift_amount;
- /* Now let's find out how much of the beginning of the line we can
- * reuse without modification. */
+ // Now let's find out how much of the beginning of the line we can
+ // reuse without modification.
verbatim_copy_end = bd.textstart;
verbatim_copy_width = bd.start_vcol;
- /* If "bd.startspaces" is set, "bd.textstart" points to the character
- * preceding the block. We have to subtract its width to obtain its
- * column number. */
+ // If "bd.startspaces" is set, "bd.textstart" points to the character
+ // preceding the block. We have to subtract its width to obtain its
+ // column number.
if (bd.startspaces) {
verbatim_copy_width -= bd.start_char_vcols;
}
@@ -482,9 +482,9 @@ static void shift_block(oparg_T *oap, int amount)
MB_PTR_ADV(verbatim_copy_end);
}
- /* If "destination_col" is different from the width of the initial
- * part of the line that will be copied, it means we encountered a tab
- * character, which we will have to partly replace with spaces. */
+ // If "destination_col" is different from the width of the initial
+ // part of the line that will be copied, it means we encountered a tab
+ // character, which we will have to partly replace with spaces.
assert(destination_col - verbatim_copy_width >= 0);
fill = (size_t)(destination_col - verbatim_copy_width);
@@ -1500,8 +1500,8 @@ int op_delete(oparg_T *oap)
did_yank = true;
}
- /* Yank into small delete register when no named register specified
- * and the delete is within one line. */
+ // Yank into small delete register when no named register specified
+ // and the delete is within one line.
if (oap->regname == 0 && oap->motion_type != kMTLineWise
&& oap->line_count == 1) {
reg = get_yank_register('-', YREG_YANK);
@@ -1659,9 +1659,8 @@ int op_delete(oparg_T *oap)
n = oap->end.col - oap->start.col + 1 - !oap->inclusive;
if (virtual_op) {
- /* fix up things for virtualedit-delete:
- * break the tabs which are going to get in our way
- */
+ // fix up things for virtualedit-delete:
+ // break the tabs which are going to get in our way
char_u *curline = get_cursor_line_ptr();
int len = (int)STRLEN(curline);
@@ -1818,12 +1817,11 @@ int op_replace(oparg_T *oap, int c)
continue; // nothing to replace
}
- /* n == number of extra chars required
- * If we split a TAB, it may be replaced by several characters.
- * Thus the number of characters may increase!
- */
- /* If the range starts in virtual space, count the initial
- * coladd offset as part of "startspaces" */
+ // n == number of extra chars required
+ // If we split a TAB, it may be replaced by several characters.
+ // Thus the number of characters may increase!
+ // If the range starts in virtual space, count the initial
+ // coladd offset as part of "startspaces"
if (virtual_op && bd.is_short && *bd.textstart == NUL) {
pos_T vpos;
@@ -2255,15 +2253,15 @@ void op_insert(oparg_T *oap, long count1)
// When a tab was inserted, and the characters in front of the tab
// have been converted to a tab as well, the column of the cursor
- // might have actually been reduced, so need to adjust here. */
+ // might have actually been reduced, so need to adjust here.
if (t1.lnum == curbuf->b_op_start_orig.lnum
&& lt(curbuf->b_op_start_orig, t1)) {
oap->start = curbuf->b_op_start_orig;
}
- /* If user has moved off this line, we don't know what to do, so do
- * nothing.
- * Also don't repeat the insert when Insert mode ended with CTRL-C. */
+ // If user has moved off this line, we don't know what to do, so do
+ // nothing.
+ // Also don't repeat the insert when Insert mode ended with CTRL-C.
if (curwin->w_cursor.lnum != oap->start.lnum || got_int) {
return;
}
@@ -2440,8 +2438,8 @@ int op_change(oparg_T *oap)
ins_len = (long)STRLEN(firstline) - pre_textlen;
if (ins_len > 0) {
- /* Subsequent calls to ml_get() flush the firstline data - take a
- * copy of the inserted text. */
+ // Subsequent calls to ml_get() flush the firstline data - take a
+ // copy of the inserted text.
ins_text = (char_u *)xmalloc((size_t)(ins_len + 1));
STRLCPY(ins_text, firstline + bd.textcol, ins_len + 1);
for (linenr = oap->start.lnum + 1; linenr <= oap->end.lnum;
@@ -2450,8 +2448,8 @@ int op_change(oparg_T *oap)
if (!bd.is_short || virtual_op) {
pos_T vpos;
- /* If the block starts in virtual space, count the
- * initial coladd offset as part of "startspaces" */
+ // If the block starts in virtual space, count the
+ // initial coladd offset as part of "startspaces"
if (bd.is_short) {
vpos.lnum = linenr;
(void)getvpos(&vpos, oap->start_vcol);
@@ -3834,9 +3832,8 @@ char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_co
*is_comment = false;
if (leader_offset != -1) {
- /* Let's check whether the line ends with an unclosed comment.
- * If the last comment leader has COM_END in flags, there's no comment.
- */
+ // Let's check whether the line ends with an unclosed comment.
+ // If the last comment leader has COM_END in flags, there's no comment.
while (*comment_flags) {
if (*comment_flags == COM_END
|| *comment_flags == ':') {
@@ -3859,11 +3856,10 @@ char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_co
return line;
}
- /* Find:
- * - COM_END,
- * - colon,
- * whichever comes first.
- */
+ // Find:
+ // - COM_END,
+ // - colon,
+ // whichever comes first.
while (*comment_flags) {
if (*comment_flags == COM_END
|| *comment_flags == ':') {
@@ -4655,8 +4651,8 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, bool
bdp->endspaces = oap->end_vcol - oap->start_vcol + 1;
}
} else {
- /* notice: this converts partly selected Multibyte characters to
- * spaces, too. */
+ // notice: this converts partly selected Multibyte characters to
+ // spaces, too.
bdp->startspaces = bdp->start_vcol - oap->start_vcol;
if (is_del && bdp->startspaces) {
bdp->startspaces = bdp->start_char_vcols - bdp->startspaces;
diff --git a/src/nvim/option.c b/src/nvim/option.c
index fb888ffd0f..05dcf737b2 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -568,12 +568,11 @@ void set_init_1(bool clean_arg)
save_file_ff(curbuf); // Buffer is unchanged
- /* Detect use of mlterm.
- * Mlterm is a terminal emulator akin to xterm that has some special
- * abilities (bidi namely).
- * NOTE: mlterm's author is being asked to 'set' a variable
- * instead of an environment variable due to inheritance.
- */
+ // Detect use of mlterm.
+ // Mlterm is a terminal emulator akin to xterm that has some special
+ // abilities (bidi namely).
+ // NOTE: mlterm's author is being asked to 'set' a variable
+ // instead of an environment variable due to inheritance.
if (os_env_exists("MLTERM")) {
set_option_value("tbidi", 1L, NULL, 0);
}
@@ -1308,16 +1307,16 @@ int do_set(char_u *arg, int opt_flags)
int comma;
bool new_value_alloced = false; // new string option was allocated
- /* When using ":set opt=val" for a global option
- * with a local value the local value will be
- * reset, use the global value here. */
+ // When using ":set opt=val" for a global option
+ // with a local value the local value will be
+ // reset, use the global value here.
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
&& ((int)options[opt_idx].indir & PV_BOTH)) {
varp = options[opt_idx].var;
}
- /* The old value is kept until we are sure that the
- * new value is valid. */
+ // The old value is kept until we are sure that the
+ // new value is valid.
oldval = *(char_u **)varp;
// When setting the local value of a global
@@ -1493,8 +1492,8 @@ int do_set(char_u *arg, int opt_flags)
}
}
- /* locate newval[] in origval[] when removing it
- * and when adding to avoid duplicates */
+ // locate newval[] in origval[] when removing it
+ // and when adding to avoid duplicates
i = 0; // init for GCC
if (removing || (flags & P_NODUP)) {
i = (int)STRLEN(newval);
@@ -1724,9 +1723,9 @@ static void did_set_option(int opt_idx, int opt_flags, int new_value, int value_
{
options[opt_idx].flags |= P_WAS_SET;
- /* When an option is set in the sandbox, from a modeline or in secure mode
- * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
- * flag. */
+ // When an option is set in the sandbox, from a modeline or in secure mode
+ // set the P_INSECURE flag. Otherwise, if a new value is stored reset the
+ // flag.
uint32_t *p = insecure_flag(curwin, opt_idx, opt_flags);
if (!value_checked && (secure
|| sandbox != 0
@@ -5259,8 +5258,8 @@ int makeset(FILE *fd, int opt_flags, int local_only)
}
}
- /* Round 1: fresh value for window-local options.
- * Round 2: other values */
+ // Round 1: fresh value for window-local options.
+ // Round 2: other values
for (; round <= 2; varp = varp_local, round++) {
if (round == 1 || (opt_flags & OPT_GLOBAL)) {
cmd = "set";
@@ -6229,13 +6228,13 @@ void buf_copy_options(buf_T *buf, int flags)
buf->b_p_sua = vim_strsave(p_sua);
buf->b_p_keymap = vim_strsave(p_keymap);
buf->b_kmap_state |= KEYMAP_INIT;
- /* This isn't really an option, but copying the langmap and IME
- * state from the current buffer is better than resetting it. */
+ // This isn't really an option, but copying the langmap and IME
+ // state from the current buffer is better than resetting it.
buf->b_p_iminsert = p_iminsert;
buf->b_p_imsearch = p_imsearch;
- /* options that are normally global but also have a local value
- * are not copied, start using the global value */
+ // options that are normally global but also have a local value
+ // are not copied, start using the global value
buf->b_p_ar = -1;
buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
buf->b_p_bkc = empty_option;
@@ -6486,8 +6485,8 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
}
}
- /* For an option that is a list of file names, find the start of the
- * last file name. */
+ // For an option that is a list of file names, find the start of the
+ // last file name.
for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; p--) {
// count number of backslashes before ' ' or ','
if (*p == ' ' || *p == ',') {
@@ -6521,10 +6520,9 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***
static char *(names[]) = { "all" };
int ic = regmatch->rm_ic; // remember the ignore-case flag
- /* do this loop twice:
- * loop == 0: count the number of matching options
- * loop == 1: copy the matching options into allocated memory
- */
+ // do this loop twice:
+ // loop == 0: count the number of matching options
+ // loop == 1: copy the matching options into allocated memory
for (loop = 0; loop <= 1; loop++) {
regmatch->rm_ic = ic;
if (xp->xp_context != EXPAND_BOOL_SETTINGS) {
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index 5b0418ed92..ed28521d80 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -54,7 +54,7 @@ int plines_win(win_T *wp, linenr_T lnum, bool winheight)
/// @return Number of filler lines above lnum
int win_get_fill(win_T *wp, linenr_T lnum)
{
- int virt_lines = decor_virtual_lines(wp, lnum);
+ int virt_lines = decor_virt_lines(wp, lnum, NULL);
// be quick when there are no filler lines
if (diffopt_filler()) {
@@ -69,7 +69,7 @@ int win_get_fill(win_T *wp, linenr_T lnum)
bool win_may_fill(win_T *wp)
{
- return (wp->w_p_diff && diffopt_filler()) || wp->w_buffer->b_virt_line_mark;
+ return (wp->w_p_diff && diffopt_filler()) || wp->w_buffer->b_virt_line_blocks;
}
/// @param winheight when true limit to window height
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index a8d4996340..570bb5e7ae 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -3643,12 +3643,12 @@ static int qf_open_new_cwindow(qf_info_T *qi, int height)
if (qf_buf != NULL) {
// Use the existing quickfix buffer
if (do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE,
- ECMD_HIDE + ECMD_OLDBUF, oldwin) == FAIL) {
+ ECMD_HIDE + ECMD_OLDBUF + ECMD_NOWINENTER, oldwin) == FAIL) {
return FAIL;
}
} else {
// Create a new quickfix buffer
- if (do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin) == FAIL) {
+ if (do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE + ECMD_NOWINENTER, oldwin) == FAIL) {
return FAIL;
}
}
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 24dc86e034..d39d6c69f1 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -461,8 +461,8 @@ static int toggle_Magic(int x)
*/
#define UCHARAT(p) ((int)*(char_u *)(p))
-/* Used for an error (down from) vim_regcomp(): give the error message, set
- * rc_did_emsg and return NULL */
+// Used for an error (down from) vim_regcomp(): give the error message, set
+// rc_did_emsg and return NULL
#define EMSG_RET_NULL(m) return (EMSG(m), rc_did_emsg = true, (void *)NULL)
#define IEMSG_RET_NULL(m) return (IEMSG(m), rc_did_emsg = true, (void *)NULL)
#define EMSG_RET_FAIL(m) return (EMSG(m), rc_did_emsg = true, FAIL)
@@ -715,9 +715,9 @@ static int reg_magic; /* magicness of the pattern: */
#define MAGIC_ON 3 /* "\m" or 'magic' */
#define MAGIC_ALL 4 /* "\v" very magic */
-static int reg_string; /* matching with a string instead of a buffer
- line */
-static int reg_strict; /* "[abc" is illegal */
+static int reg_string; // matching with a string instead of a buffer
+ // line
+static int reg_strict; // "[abc" is illegal
/*
* META contains all characters that may be magic, except '^' and '$'.
@@ -741,10 +741,10 @@ static char_u META_flags[] = {
1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1
};
-static int curchr; /* currently parsed character */
-/* Previous character. Note: prevchr is sometimes -1 when we are not at the
- * start, eg in /[ ^I]^ the pattern was never found even if it existed,
- * because ^ was taken to be magic -- webb */
+static int curchr; // currently parsed character
+// Previous character. Note: prevchr is sometimes -1 when we are not at the
+// start, eg in /[ ^I]^ the pattern was never found even if it existed,
+// because ^ was taken to be magic -- webb
static int prevchr;
static int prevprevchr; /* previous-previous character */
static int nextchr; /* used for ungetchr() */
@@ -2835,21 +2835,22 @@ static int peekchr(void)
curchr = Magic(curchr);
break;
case '*':
- /* * is not magic as the very first character, eg "?*ptr", when
- * after '^', eg "/^*ptr" and when after "\(", "\|", "\&". But
- * "\(\*" is not magic, thus must be magic if "after_slash" */
+ // * is not magic as the very first character, eg "?*ptr", when
+ // after '^', eg "/^*ptr" and when after "\(", "\|", "\&". But
+ // "\(\*" is not magic, thus must be magic if "after_slash"
if (reg_magic >= MAGIC_ON
&& !at_start
&& !(prev_at_start && prevchr == Magic('^'))
&& (after_slash
|| (prevchr != Magic('(')
&& prevchr != Magic('&')
- && prevchr != Magic('|'))))
+ && prevchr != Magic('|')))) {
curchr = Magic('*');
+ }
break;
case '^':
- /* '^' is only magic as the very first character and if it's after
- * "\(", "\|", "\&' or "\n" */
+ // '^' is only magic as the very first character and if it's after
+ // "\(", "\|", "\&' or "\n"
if (reg_magic >= MAGIC_OFF
&& (at_start
|| reg_magic == MAGIC_ALL
@@ -2865,8 +2866,8 @@ static int peekchr(void)
}
break;
case '$':
- /* '$' is only magic as the very last char and if it's in front of
- * either "\|", "\)", "\&", or "\n" */
+ // '$' is only magic as the very last char and if it's in front of
+ // either "\|", "\)", "\&", or "\n"
if (reg_magic >= MAGIC_OFF) {
char_u *p = regparse + 1;
bool is_magic_all = (reg_magic == MAGIC_ALL);
@@ -5811,8 +5812,8 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e
if (bytelen != NULL)
*bytelen = 0;
for (;; ) {
- /* Since getting one line may invalidate the other, need to make copy.
- * Slow! */
+ // Since getting one line may invalidate the other, need to make copy.
+ // Slow!
if (rex.line != reg_tofree) {
len = (int)STRLEN(rex.line);
if (reg_tofree == NULL || len >= (int)reg_tofreelen) {
@@ -6445,9 +6446,9 @@ static int cstrncmp(char_u *s1, char_u *s2, int *n)
return result;
}
-/***************************************************************
-* regsub stuff *
-***************************************************************/
+////////////////////////////////////////////////////////////////
+// regsub stuff //
+////////////////////////////////////////////////////////////////
/* This stuff below really confuses cc on an SGI -- webb */
@@ -6512,9 +6513,10 @@ char_u *regtilde(char_u *source, int magic)
memmove(tmpsub, newsub, (size_t)len);
/* interpret tilde */
memmove(tmpsub + len, reg_prev_sub, (size_t)prevlen);
- /* copy postfix */
- if (!magic)
- ++p; /* back off \ */
+ // copy postfix
+ if (!magic) {
+ p++; // back off backslash
+ }
STRCPY(tmpsub + len + prevlen, p + 1);
if (newsub != source) /* already allocated newsub */
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index c8b7190b4a..0eb061034f 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -48,14 +48,14 @@ enum {
NFA_MATCH,
NFA_EMPTY, /* matches 0-length */
- NFA_START_COLL, /* [abc] start */
- NFA_END_COLL, /* [abc] end */
- NFA_START_NEG_COLL, /* [^abc] start */
- NFA_END_NEG_COLL, /* [^abc] end (postfix only) */
- NFA_RANGE, /* range of the two previous items
- * (postfix only) */
- NFA_RANGE_MIN, /* low end of a range */
- NFA_RANGE_MAX, /* high end of a range */
+ NFA_START_COLL, // [abc] start
+ NFA_END_COLL, // [abc] end
+ NFA_START_NEG_COLL, // [^abc] start
+ NFA_END_NEG_COLL, // [^abc] end (postfix only)
+ NFA_RANGE, // range of the two previous items
+ // (postfix only)
+ NFA_RANGE_MIN, // low end of a range
+ NFA_RANGE_MAX, // high end of a range
NFA_CONCAT, // concatenate two previous items (postfix
// only)
@@ -88,9 +88,9 @@ enum {
NFA_END_INVISIBLE,
NFA_END_INVISIBLE_NEG,
NFA_END_PATTERN,
- NFA_COMPOSING, /* Next nodes in NFA are part of the
- composing multibyte char */
- NFA_END_COMPOSING, /* End of a composing char in the NFA */
+ NFA_COMPOSING, // Next nodes in NFA are part of the
+ // composing multibyte char
+ NFA_END_COMPOSING, // End of a composing char in the NFA
NFA_ANY_COMPOSING, // \%C: Any composing characters.
NFA_OPT_CHARS, /* \%[abc] */
@@ -256,9 +256,9 @@ static char_u e_ill_char_class[] = N_(
"E877: (NFA regexp) Invalid character class: %" PRId64);
static char_u e_value_too_large[] = N_("E951: \\% value too large");
-/* Since the out pointers in the list are always
- * uninitialized, we use the pointers themselves
- * as storage for the Ptrlists. */
+// Since the out pointers in the list are always
+// uninitialized, we use the pointers themselves
+// as storage for the Ptrlists.
typedef union Ptrlist Ptrlist;
union Ptrlist {
Ptrlist *next;
@@ -310,9 +310,9 @@ struct nfa_pim_S {
typedef struct {
nfa_state_T *state;
int count;
- nfa_pim_T pim; /* if pim.result != NFA_PIM_UNUSED: postponed
- * invisible match */
- regsubs_T subs; /* submatch info, only party used */
+ nfa_pim_T pim; // if pim.result != NFA_PIM_UNUSED: postponed
+ // invisible match
+ regsubs_T subs; // submatch info, only party used
} nfa_thread_T;
// nfa_list_T contains the alternative NFA execution states.
@@ -1675,13 +1675,13 @@ collection:
}
/* Try collating class like [. .] */
if (collclass != 0) {
- startc = collclass; /* allow [.a.]-x as a range */
- /* Will emit the proper atom at the end of the
- * while loop. */
+ startc = collclass; // allow [.a.]-x as a range
+ // Will emit the proper atom at the end of the
+ // while loop.
}
}
- /* Try a range like 'a-x' or '\t-z'. Also allows '-' as a
- * start character. */
+ // Try a range like 'a-x' or '\t-z'. Also allows '-' as a
+ // start character.
if (*regparse == '-' && oldstartc != -1) {
emit_range = true;
startc = oldstartc;
@@ -1689,11 +1689,10 @@ collection:
continue; // reading the end of the range
}
- /* Now handle simple and escaped characters.
- * Only "\]", "\^", "\]" and "\\" are special in Vi. Vim
- * accepts "\t", "\e", etc., but only when the 'l' flag in
- * 'cpoptions' is not included.
- */
+ // Now handle simple and escaped characters.
+ // Only "\]", "\^", "\]" and "\\" are special in Vi. Vim
+ // accepts "\t", "\e", etc., but only when the 'l' flag in
+ // 'cpoptions' is not included.
if (*regparse == '\\'
&& regparse + 1 <= endp
&& (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
@@ -1736,13 +1735,14 @@ collection:
}
if (endc > startc + 2) {
- /* Emit a range instead of the sequence of
- * individual characters. */
- if (startc == 0)
- /* \x00 is translated to \x0a, start at \x01. */
+ // Emit a range instead of the sequence of
+ // individual characters.
+ if (startc == 0) {
+ // \x00 is translated to \x0a, start at \x01.
EMIT(1);
- else
- --post_ptr; /* remove NFA_CONCAT */
+ } else {
+ post_ptr--; // remove NFA_CONCAT
+ }
EMIT(endc);
EMIT(NFA_RANGE);
EMIT(NFA_CONCAT);
@@ -1755,8 +1755,8 @@ collection:
EMIT(NFA_CONCAT);
}
} else {
- /* Emit the range. "startc" was already emitted, so
- * skip it. */
+ // Emit the range. "startc" was already emitted, so
+ // skip it.
for (c = startc + 1; c <= endc; c++) {
EMIT(c);
EMIT(NFA_CONCAT);
@@ -1765,19 +1765,20 @@ collection:
emit_range = false;
startc = -1;
} else {
- /* This char (startc) is not part of a range. Just
- * emit it.
- * Normally, simply emit startc. But if we get char
- * code=0 from a collating char, then replace it with
- * 0x0a.
- * This is needed to completely mimic the behaviour of
- * the backtracking engine. */
+ // This char (startc) is not part of a range. Just
+ // emit it.
+ // Normally, simply emit startc. But if we get char
+ // code=0 from a collating char, then replace it with
+ // 0x0a.
+ // This is needed to completely mimic the behaviour of
+ // the backtracking engine.
if (startc == NFA_NEWL) {
- /* Line break can't be matched as part of the
- * collection, add an OR below. But not for negated
- * range. */
- if (!negated)
+ // Line break can't be matched as part of the
+ // collection, add an OR below. But not for negated
+ // range.
+ if (!negated) {
extra = NFA_ADD_NL;
+ }
} else {
if (got_coll_char == true && startc == 0) {
EMIT(0x0a);
@@ -1831,14 +1832,14 @@ nfa_do_multibyte:
|| utf_iscomposing(c)) {
int i = 0;
- /* A base character plus composing characters, or just one
- * or more composing characters.
- * This requires creating a separate atom as if enclosing
- * the characters in (), where NFA_COMPOSING is the ( and
- * NFA_END_COMPOSING is the ). Note that right now we are
- * building the postfix form, not the NFA itself;
- * a composing char could be: a, b, c, NFA_COMPOSING
- * where 'b' and 'c' are chars with codes > 256. */
+ // A base character plus composing characters, or just one
+ // or more composing characters.
+ // This requires creating a separate atom as if enclosing
+ // the characters in (), where NFA_COMPOSING is the ( and
+ // NFA_END_COMPOSING is the ). Note that right now we are
+ // building the postfix form, not the NFA itself;
+ // a composing char could be: a, b, c, NFA_COMPOSING
+ // where 'b' and 'c' are chars with codes > 256. */
for (;; ) {
EMIT(c);
if (i > 0)
@@ -3109,9 +3110,9 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
case NFA_END_COLL:
case NFA_END_NEG_COLL:
- /* On the stack is the sequence starting with NFA_START_COLL or
- * NFA_START_NEG_COLL and all possible characters. Patch it to
- * add the output to the start. */
+ // On the stack is the sequence starting with NFA_START_COLL or
+ // NFA_START_NEG_COLL and all possible characters. Patch it to
+ // add the output to the start.
if (nfa_calc_size == true) {
nstate++;
break;
@@ -3233,12 +3234,12 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
if (before)
n = *++p; /* get the count */
- /* The \@= operator: match the preceding atom with zero width.
- * The \@! operator: no match for the preceding atom.
- * The \@<= operator: match for the preceding atom.
- * The \@<! operator: no match for the preceding atom.
- * Surrounds the preceding atom with START_INVISIBLE and
- * END_INVISIBLE, similarly to MOPEN. */
+ // The \@= operator: match the preceding atom with zero width.
+ // The \@! operator: no match for the preceding atom.
+ // The \@<= operator: match for the preceding atom.
+ // The \@<! operator: no match for the preceding atom.
+ // Surrounds the preceding atom with START_INVISIBLE and
+ // END_INVISIBLE, similarly to MOPEN.
if (nfa_calc_size == true) {
nstate += pattern ? 4 : 2;
@@ -3269,11 +3270,12 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
patch(e.out, s1);
PUSH(frag(s, list1(&s1->out)));
if (before) {
- if (n <= 0)
- /* See if we can guess the maximum width, it avoids a
- * lot of pointless tries. */
+ if (n <= 0) {
+ // See if we can guess the maximum width, it avoids a
+ // lot of pointless tries.
n = nfa_max_width(e.start, 0);
- s->val = n; /* store the count */
+ }
+ s->val = n; // store the count
}
}
break;
@@ -3516,8 +3518,8 @@ static void nfa_postprocess(nfa_regprog_T *prog)
directly = ch_follows * 10 < ch_invisible;
}
} else {
- /* normal invisible, first do the one with the
- * highest failure chance */
+ // normal invisible, first do the one with the
+ // highest failure chance
directly = ch_follows < ch_invisible;
}
}
@@ -4012,8 +4014,8 @@ static regsubs_T *addstate(
case NFA_ZEND:
case NFA_SPLIT:
case NFA_EMPTY:
- /* These nodes are not added themselves but their "out" and/or
- * "out1" may be added below. */
+ // These nodes are not added themselves but their "out" and/or
+ // "out1" may be added below.
break;
case NFA_BOL:
@@ -4051,21 +4053,20 @@ static regsubs_T *addstate(
case NFA_ZOPEN9:
case NFA_NOPEN:
case NFA_ZSTART:
- /* These nodes need to be added so that we can bail out when it
- * was added to this list before at the same position to avoid an
- * endless loop for "\(\)*" */
+ // These nodes need to be added so that we can bail out when it
+ // was added to this list before at the same position to avoid an
+ // endless loop for "\(\)*"
default:
if (state->lastlist[nfa_ll_index] == l->id && state->c != NFA_SKIP) {
- /* This state is already in the list, don't add it again,
- * unless it is an MOPEN that is used for a backreference or
- * when there is a PIM. For NFA_MATCH check the position,
- * lower position is preferred. */
+ // This state is already in the list, don't add it again,
+ // unless it is an MOPEN that is used for a backreference or
+ // when there is a PIM. For NFA_MATCH check the position,
+ // lower position is preferred.
if (!rex.nfa_has_backref && pim == NULL && !l->has_pim
&& state->c != NFA_MATCH) {
-
- /* When called from addstate_here() do insert before
- * existing states. */
+ // When called from addstate_here() do insert before
+ // existing states.
if (add_here) {
for (k = 0; k < l->n && k < listindex; ++k) {
if (l->t[k].state->id == state->id) {
@@ -4088,10 +4089,11 @@ skip_add:
}
}
- /* Do not add the state again when it exists with the same
- * positions. */
- if (has_state_with_pos(l, state, subs, pim))
+ // Do not add the state again when it exists with the same
+ // positions.
+ if (has_state_with_pos(l, state, subs, pim)) {
goto skip_add;
+ }
}
// When there are backreferences or PIMs the number of states may
@@ -4362,9 +4364,9 @@ static regsubs_T *addstate_here(
int count;
int listidx = *ip;
- /* First add the state(s) at the end, so that we know how many there are.
- * Pass the listidx as offset (avoids adding another argument to
- * addstate(). */
+ // First add the state(s) at the end, so that we know how many there are.
+ // Pass the listidx as offset (avoids adding another argument to
+ // addstate().
regsubs_T *r = addstate(l, state, subs, pim, -listidx - ADDSTATE_HERE_OFFSET);
if (r == NULL) {
return NULL;
@@ -4385,8 +4387,8 @@ static regsubs_T *addstate_here(
l->t[listidx] = l->t[l->n - 1];
} else if (count > 1) {
if (l->n + count - 1 >= l->len) {
- /* not enough space to move the new states, reallocate the list
- * and move the states to the right position */
+ // not enough space to move the new states, reallocate the list
+ // and move the states to the right position
const int newlen = l->len * 3 / 2 + 50;
const size_t newsize = newlen * sizeof(nfa_thread_T);
@@ -4408,8 +4410,8 @@ static regsubs_T *addstate_here(
xfree(l->t);
l->t = newl;
} else {
- /* make space for new states, then move them from the
- * end to the current position */
+ // make space for new states, then move them from the
+ // end to the current position
memmove(&(l->t[listidx + count]),
&(l->t[listidx + 1]),
sizeof(nfa_thread_T) * (l->n - listidx - 1));
@@ -6582,10 +6584,11 @@ static long nfa_regexec_both(char_u *line, colnr_T startcol,
}
if (prog->regstart != NUL) {
- /* Skip ahead until a character we know the match must start with.
- * When there is none there is no match. */
- if (skip_to_start(prog->regstart, &col) == FAIL)
+ // Skip ahead until a character we know the match must start with.
+ // When there is none there is no match.
+ if (skip_to_start(prog->regstart, &col) == FAIL) {
return 0L;
+ }
// If match_text is set it contains the full text that must match.
// Nothing else to try. Doesn't handle combining chars well.
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 32eb28e761..fcd428ba1b 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -694,7 +694,7 @@ void conceal_check_cursor_line(void)
if (curwin->w_p_cole > 0 && (conceal_cursor_used != should_conceal)) {
redrawWinline(curwin, curwin->w_cursor.lnum);
// Need to recompute cursor column, e.g., when starting Visual mode
- // without concealing. */
+ // without concealing.
curs_columns(curwin, true);
}
}
@@ -2372,11 +2372,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
filler_lines = 0;
area_highlighting = true;
}
- int virtual_lines = decor_virtual_lines(wp, lnum);
- filler_lines += virtual_lines;
+ VirtLines virt_lines = KV_INITIAL_VALUE;
+ int n_virt_lines = decor_virt_lines(wp, lnum, &virt_lines);
+ filler_lines += n_virt_lines;
if (lnum == wp->w_topline) {
filler_lines = wp->w_topfill;
- virtual_lines = MIN(virtual_lines, filler_lines);
+ n_virt_lines = MIN(n_virt_lines, filler_lines);
}
filler_todo = filler_lines;
@@ -2904,7 +2905,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
if (draw_state == WL_SBR - 1 && n_extra == 0) {
draw_state = WL_SBR;
- if (filler_todo > filler_lines - virtual_lines) {
+ if (filler_todo > filler_lines - n_virt_lines) {
// TODO(bfredl): check this doesn't inhibit TUI-style
// clear-to-end-of-line.
c_extra = ' ';
@@ -4423,12 +4424,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
int draw_col = col - boguscols;
if (filler_todo > 0) {
- int index = filler_todo - (filler_lines - virtual_lines);
+ int index = filler_todo - (filler_lines - n_virt_lines);
if (index > 0) {
- int fpos = kv_size(buf->b_virt_lines) - index;
- assert(fpos >= 0);
- int offset = buf->b_virt_line_leftcol ? 0 : win_col_offset;
- draw_virt_text_item(buf, offset, kv_A(buf->b_virt_lines, fpos),
+ int i = kv_size(virt_lines) - index;
+ assert(i >= 0);
+ int offset = kv_A(virt_lines, i).left_col ? 0 : win_col_offset;
+ draw_virt_text_item(buf, offset, kv_A(virt_lines, i).line,
kHlModeReplace, grid->Columns, offset);
}
} else {
@@ -4506,6 +4507,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
cap_col = 0;
}
+ kv_destroy(virt_lines);
xfree(p_extra_free);
return row;
}
@@ -4827,8 +4829,8 @@ static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol,
}
if (clear_next) {
- /* Clear the second half of a double-wide character of which the left
- * half was overwritten with a single-wide character. */
+ // Clear the second half of a double-wide character of which the left
+ // half was overwritten with a single-wide character.
schar_from_ascii(grid->chars[off_to], ' ');
end_dirty++;
}
@@ -5175,9 +5177,9 @@ void win_redr_status_matches(expand_T *xp, int num_matches, char_u **matches, in
}
wild_menu_showing = WM_SCROLLED;
} else {
- /* Create status line if needed by setting 'laststatus' to 2.
- * Set 'winminheight' to zero to avoid that the window is
- * resized. */
+ // Create status line if needed by setting 'laststatus' to 2.
+ // Set 'winminheight' to zero to avoid that the window is
+ // resized.
if (lastwin->w_status_height == 0) {
save_p_ls = p_ls;
save_p_wmh = p_wmh;
@@ -7324,8 +7326,8 @@ void draw_tabline(void)
}
}
- /* Reset the flag here again, in case evaluating 'tabline' causes it to be
- * set. */
+ // Reset the flag here again, in case evaluating 'tabline' causes it to be
+ // set.
redraw_tabline = false;
}
@@ -7390,9 +7392,9 @@ int fillchar_status(int *attr, win_T *wp)
*attr = win_hl_attr(wp, HLF_SNC);
fill = wp->w_p_fcs_chars.stlnc;
}
- /* Use fill when there is highlighting, and highlighting of current
- * window differs, or the fillchars differ, or this is not the
- * current window */
+ // Use fill when there is highlighting, and highlighting of current
+ // window differs, or the fillchars differ, or this is not the
+ // current window
if (*attr != 0 && ((win_hl_attr(wp, HLF_S) != win_hl_attr(wp, HLF_SNC)
|| !is_curwin || ONE_WINDOW)
|| (wp->w_p_fcs_chars.stl != wp->w_p_fcs_chars.stlnc))) {
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 1b54d12042..c3a5f8dbe6 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -699,8 +699,8 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir,
*/
if (vim_strchr(p_cpo, CPO_SEARCH) != NULL) {
if (nmatched > 1) {
- /* end is in next line, thus no match in
- * this line */
+ // end is in next line, thus no match in
+ // this line
match_ok = false;
break;
}
@@ -758,10 +758,10 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir,
*/
match_ok = false;
for (;; ) {
- /* Remember a position that is before the start
- * position, we use it if it's the last match in
- * the line. Always accept a position after
- * wrapping around. */
+ // Remember a position that is before the start
+ // position, we use it if it's the last match in
+ // the line. Always accept a position after
+ // wrapping around.
if (loop
|| ((options & SEARCH_END)
? (lnum + regmatch.endpos[0].lnum
@@ -890,9 +890,9 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir,
break;
}
- /* Cancel searching if a character was typed. Used for
- * 'incsearch'. Don't check too often, that would slowdown
- * searching too much. */
+ // Cancel searching if a character was typed. Used for
+ // 'incsearch'. Don't check too often, that would slowdown
+ // searching too much.
if ((options & SEARCH_PEEK)
&& ((lnum - pos->lnum) & 0x3f) == 0
&& char_avail()) {
@@ -1082,8 +1082,8 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
}
}
- /* If the cursor is in a closed fold, don't find another match in the same
- * fold. */
+ // If the cursor is in a closed fold, don't find another match in the same
+ // fold.
if (dirc == '/') {
if (hasFolding(pos.lnum, NULL, &pos.lnum)) {
pos.col = MAXCOL - 2; // avoid overflow when adding 1
@@ -1892,8 +1892,8 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
} else if (!cpo_bsl) {
int col, bslcnt = 0;
- /* Set "match_escaped" if there are an odd number of
- * backslashes. */
+ // Set "match_escaped" if there are an odd number of
+ // backslashes.
for (col = pos.col; check_prevcol(linep, col, '\\', &col); ) {
bslcnt++;
}
@@ -2033,8 +2033,8 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|| (lisp && comment_col != MAXCOL
&& pos.col == (colnr_T)comment_col)) {
if (pos.lnum == curbuf->b_ml.ml_line_count // end of file
- /* line is exhausted and comment with it,
- * don't search for match in code */
+ // line is exhausted and comment with it,
+ // don't search for match in code
|| lispcomm) {
break;
}
@@ -2271,8 +2271,8 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
break;
}
- /* Check for match outside of quotes, and inside of
- * quotes when the start is also inside of quotes. */
+ // Check for match outside of quotes, and inside of
+ // quotes when the start is also inside of quotes.
if ((!inquote || start_in_quotes == kTrue)
&& (c == initc || c == findc)) {
int col, bslcnt = 0;
@@ -2340,8 +2340,8 @@ static int check_linecomment(const char_u *line)
}
} else {
while ((p = vim_strchr(p, '/')) != NULL) {
- /* accept a double /, unless it's preceded with * and followed by *,
- * because * / / * is an end and start of a C comment */
+ // accept a double /, unless it's preceded with * and followed by *,
+ // because * / / * is an end and start of a C comment
if (p[1] == '/' && (p == line || p[-1] != '*' || p[2] != '*')) {
break;
}
@@ -2427,9 +2427,9 @@ void showmatch(int c)
showruler(false);
setcursor();
ui_flush();
- /* Restore dollar_vcol(), because setcursor() may call curs_rows()
- * which resets it if the matching position is in a previous line
- * and has a higher column number. */
+ // Restore dollar_vcol(), because setcursor() may call curs_rows()
+ // which resets it if the matching position is in a previous line
+ // and has a higher column number.
dollar_vcol = save_dollar_vcol;
/*
@@ -2595,8 +2595,8 @@ bool findpar(bool *pincl, int dir, long count, int what, int both)
bool first; // true on first line
linenr_T fold_first; // first line of a closed fold
linenr_T fold_last; // last line of a closed fold
- bool fold_skipped; /* true if a closed fold was skipped this
- iteration */
+ bool fold_skipped; // true if a closed fold was skipped this
+ // iteration
curr = curwin->w_cursor.lnum;
@@ -2658,10 +2658,10 @@ static int inmacro(char_u *opt, char_u *s)
{
char_u *macro;
- for (macro = opt; macro[0]; ++macro) {
- /* Accept two characters in the option being equal to two characters
- * in the line. A space in the option matches with a space in the
- * line or the line having ended. */
+ for (macro = opt; macro[0]; macro++) {
+ // Accept two characters in the option being equal to two characters
+ // in the line. A space in the option matches with a space in the
+ // line or the line having ended.
if ( (macro[0] == s[0]
|| (macro[0] == ' '
&& (s[0] == NUL || s[0] == ' ')))
@@ -2756,8 +2756,8 @@ int fwd_word(long count, int bigword, int eol)
curwin->w_cursor.coladd = 0;
cls_bigword = bigword;
while (--count >= 0) {
- /* When inside a range of folded lines, move to the last char of the
- * last line. */
+ // When inside a range of folded lines, move to the last char of the
+ // last line.
if (hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) {
coladvance(MAXCOL);
}
@@ -3675,9 +3675,9 @@ again:
xfree(epat);
if (r < 1 || lt(curwin->w_cursor, old_end)) {
- /* Can't find other end or it's before the previous end. Could be a
- * HTML tag that doesn't have a matching end. Search backwards for
- * another starting tag. */
+ // Can't find other end or it's before the previous end. Could be a
+ // HTML tag that doesn't have a matching end. Search backwards for
+ // another starting tag.
count = 1;
curwin->w_cursor = start_pos;
goto again;
@@ -3729,8 +3729,8 @@ again:
}
if (VIsual_active) {
- /* If the end is before the start there is no text between tags, select
- * the char under the cursor. */
+ // If the end is before the start there is no text between tags, select
+ // the char under the cursor.
if (lt(end_pos, start_pos)) {
curwin->w_cursor = start_pos;
} else if (*p_sel == 'e') {
@@ -3744,8 +3744,8 @@ again:
oap->start = start_pos;
oap->motion_type = kMTCharWise;
if (lt(end_pos, start_pos)) {
- /* End is before the start: there is no text between tags; operate
- * on an empty area. */
+ // End is before the start: there is no text between tags; operate
+ // on an empty area.
curwin->w_cursor = start_pos;
oap->inclusive = false;
} else {
@@ -4112,10 +4112,10 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
first_col = find_prev_quote(line, col_start, quotechar, NULL);
}
}
- /* The cursor is on a quote, we don't know if it's the opening or
- * closing quote. Search from the start of the line to find out.
- * Also do this when there is a Visual area, a' may leave the cursor
- * in between two strings. */
+ // The cursor is on a quote, we don't know if it's the opening or
+ // closing quote. Search from the start of the line to find out.
+ // Also do this when there is a Visual area, a' may leave the cursor
+ // in between two strings.
col_start = 0;
for (;; ) {
// Find open quote character.
@@ -4169,18 +4169,17 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
}
}
- /* Set start position. After vi" another i" must include the ".
- * For v2i" include the quotes. */
+ // Set start position. After vi" another i" must include the ".
+ // For v2i" include the quotes.
if (!include && count < 2
&& (vis_empty || !inside_quotes)) {
++col_start;
}
curwin->w_cursor.col = col_start;
if (VIsual_active) {
- /* Set the start of the Visual area when the Visual area was empty, we
- * were just inside quotes or the Visual area didn't start at a quote
- * and didn't include a quote.
- */
+ // Set the start of the Visual area when the Visual area was empty, we
+ // were just inside quotes or the Visual area didn't start at a quote
+ // and didn't include a quote.
if (vis_empty
|| (vis_bef_curs
&& !selected_quote
@@ -4211,9 +4210,9 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
dec_cursor();
}
} else {
- /* Cursor is at start of Visual area. Set the end of the Visual
- * area when it was just inside quotes or it didn't end at a
- * quote. */
+ // Cursor is at start of Visual area. Set the end of the Visual
+ // area when it was just inside quotes or it didn't end at a
+ // quote.
if (inside_quotes
|| (!selected_quote
&& line[VIsual.col] != quotechar
@@ -4911,14 +4910,14 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
msg_home_replace(files[depth_displayed].name);
MSG_PUTS(" -->\n");
}
- if (!got_int) { /* don't display if 'q' typed
- for "--more--" message */
+ if (!got_int) { // don't display if 'q' typed
+ // for "--more--" message
for (i = 0; i <= depth_displayed; i++) {
MSG_PUTS(" ");
}
if (new_fname != NULL) {
- /* using "new_fname" is more reliable, e.g., when
- * 'includeexpr' is set. */
+ // using "new_fname" is more reliable, e.g., when
+ // 'includeexpr' is set.
msg_outtrans_attr(new_fname, HL_ATTR(HLF_D));
} else {
/*
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 1e14f988f1..b194620b53 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -929,9 +929,9 @@ static void syn_update_ends(bool startofline)
stateitem_T *cur_si;
if (startofline) {
- /* Check for a match carried over from a previous line with a
- * contained region. The match ends as soon as the region ends. */
- for (int i = 0; i < current_state.ga_len; ++i) {
+ // Check for a match carried over from a previous line with a
+ // contained region. The match ends as soon as the region ends.
+ for (int i = 0; i < current_state.ga_len; i++) {
cur_si = &CUR_STATE(i);
if (cur_si->si_idx >= 0
&& (SYN_ITEMS(syn_block)[cur_si->si_idx]).sp_type
@@ -1335,8 +1335,8 @@ static synstate_T *store_current_state(void)
if (syn_block->b_sst_freecount == 0) {
sp = NULL;
} else {
- /* Take the first item from the free list and put it in the used
- * list, after *sp */
+ // Take the first item from the free list and put it in the used
+ // list, after *sp
p = syn_block->b_sst_firstfree;
syn_block->b_sst_firstfree = p->sst_next;
--syn_block->b_sst_freecount;
@@ -1359,8 +1359,8 @@ static synstate_T *store_current_state(void)
clear_syn_state(sp);
sp->sst_stacksize = current_state.ga_len;
if (current_state.ga_len > SST_FIX_STATES) {
- /* Need to clear it, might be something remaining from when the
- * length was less than SST_FIX_STATES. */
+ // Need to clear it, might be something remaining from when the
+ // length was less than SST_FIX_STATES.
ga_init(&sp->sst_union.sst_ga, (int)sizeof(bufstate_T), 1);
ga_grow(&sp->sst_union.sst_ga, current_state.ga_len);
sp->sst_union.sst_ga.ga_len = current_state.ga_len;
@@ -1458,24 +1458,24 @@ static bool syn_stack_equal(synstate_T *sp)
if (bp[i].bs_extmatch == CUR_STATE(i).si_extmatch) {
continue;
}
- /* When the extmatch pointers are different, the strings in
- * them can still be the same. Check if the extmatch
- * references are equal. */
+ // When the extmatch pointers are different, the strings in
+ // them can still be the same. Check if the extmatch
+ // references are equal.
bsx = bp[i].bs_extmatch;
six = CUR_STATE(i).si_extmatch;
- /* If one of the extmatch pointers is NULL the states are
- * different. */
+ // If one of the extmatch pointers is NULL the states are
+ // different.
if (bsx == NULL || six == NULL) {
break;
}
int j;
- for (j = 0; j < NSUBEXP; ++j) {
- /* Check each referenced match string. They must all be
- * equal. */
+ for (j = 0; j < NSUBEXP; j++) {
+ // Check each referenced match string. They must all be
+ // equal.
if (bsx->matches[j] != six->matches[j]) {
- /* If the pointer is different it can still be the
- * same text. Compare the strings, ignore case when
- * the start item has the sp_ic flag set. */
+ // If the pointer is different it can still be the
+ // same text. Compare the strings, ignore case when
+ // the start item has the sp_ic flag set.
if (bsx->matches[j] == NULL || six->matches[j] == NULL) {
break;
}
@@ -1749,8 +1749,8 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
&& (syn_block->b_keywtab.ht_used > 0
|| syn_block->b_keywtab_ic.ht_used > 0);
- /* Init the list of zero-width matches with a nextlist. This is used to
- * avoid matching the same item in the same position twice. */
+ // Init the list of zero-width matches with a nextlist. This is used to
+ // avoid matching the same item in the same position twice.
ga_init(&zero_width_next_ga, (int)sizeof(int), 10);
// use syntax iskeyword option
@@ -1867,9 +1867,9 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
: in_id_list(cur_si,
cur_si->si_cont_list, &spp->sp_syn,
spp->sp_flags & HL_CONTAINED)))) {
- /* If we already tried matching in this line, and
- * there isn't a match before next_match_col, skip
- * this item. */
+ // If we already tried matching in this line, and
+ // there isn't a match before next_match_col, skip
+ // this item.
if (spp->sp_line_id == current_line_id
&& spp->sp_startcol >= next_match_col) {
continue;
@@ -2037,9 +2037,9 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
keep_next_list = true;
zero_width_next_list = true;
- /* Add the index to a list, so that we can check
- * later that we don't match it again (and cause an
- * endless loop). */
+ // Add the index to a list, so that we can check
+ // later that we don't match it again (and cause an
+ // endless loop).
GA_APPEND(int, &zero_width_next_ga, next_match_idx);
next_match_idx = -1;
} else {
@@ -2136,10 +2136,10 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
*can_spell = !in_id_list(sip, sip->si_cont_list, &sps, 0);
}
} else {
- /* The @Spell cluster is defined: Do spelling in items with
- * the @Spell cluster. But not when @NoSpell is also there.
- * At the toplevel only spell check when ":syn spell toplevel"
- * was used. */
+ // The @Spell cluster is defined: Do spelling in items with
+ // the @Spell cluster. But not when @NoSpell is also there.
+ // At the toplevel only spell check when ":syn spell toplevel"
+ // was used.
if (current_trans_id == 0) {
*can_spell = (syn_block->b_syn_spell == SYNSPL_TOP);
} else {
@@ -2216,8 +2216,8 @@ static bool did_match_already(int idx, garray_T *gap)
}
}
- /* Zero-width matches with a nextgroup argument are not put on the syntax
- * stack, and can only be matched once anyway. */
+ // Zero-width matches with a nextgroup argument are not put on the syntax
+ // stack, and can only be matched once anyway.
for (int i = gap->ga_len; --i >= 0; ) {
if (((int *)(gap->ga_data))[i] == idx) {
return true;
@@ -2353,8 +2353,8 @@ static void check_state_ends(void)
next_match_col = MAXCOL;
break;
} else {
- /* handle next_list, unless at end of line and no "skipnl" or
- * "skipempty" */
+ // handle next_list, unless at end of line and no "skipnl" or
+ // "skipempty"
current_next_list = cur_si->si_next_list;
current_next_flags = cur_si->si_flags;
if (!(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index c22d344878..94f51c3b24 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -284,17 +284,16 @@ int do_tag(char_u *tag, int type, int count, int forceit, int verbose)
tagstackidx = 0;
goto end_do_tag;
}
- /* We weren't at the bottom of the stack, so jump all the
- * way to the bottom now.
- */
+ // We weren't at the bottom of the stack, so jump all the
+ // way to the bottom now.
tagstackidx = 0;
} else if (tagstackidx >= tagstacklen) { // count == 0?
EMSG(_(topmsg));
goto end_do_tag;
}
- /* Make a copy of the fmark, autocommands may invalidate the
- * tagstack before it's used. */
+ // Make a copy of the fmark, autocommands may invalidate the
+ // tagstack before it's used.
saved_fmark = tagstack[tagstackidx].fmark;
if (saved_fmark.fnum != curbuf->b_fnum) {
/*
@@ -306,8 +305,8 @@ int do_tag(char_u *tag, int type, int count, int forceit, int verbose)
tagstackidx = oldtagstackidx; // back to old posn
goto end_do_tag;
}
- /* A BufReadPost autocommand may jump to the '" mark, but
- * we don't what that here. */
+ // A BufReadPost autocommand may jump to the '" mark, but
+ // we don't what that here.
curwin->w_cursor.lnum = saved_fmark.mark.lnum;
} else {
setpcmark();
@@ -488,9 +487,9 @@ int do_tag(char_u *tag, int type, int count, int forceit, int verbose)
// found: all matches found.
}
- /* If there already were some matches for the same name, move them
- * to the start. Avoids that the order changes when using
- * ":tnext" and jumping to another file. */
+ // If there already were some matches for the same name, move them
+ // to the start. Avoids that the order changes when using
+ // ":tnext" and jumping to another file.
if (!new_tag && !other_name) {
int j, k;
int idx = 0;
@@ -561,9 +560,9 @@ int do_tag(char_u *tag, int type, int count, int forceit, int verbose)
}
if (cur_match >= num_matches) {
- /* Avoid giving this error when a file wasn't found and we're
- * looking for a match in another file, which wasn't found.
- * There will be an EMSG("file doesn't exist") below then. */
+ // Avoid giving this error when a file wasn't found and we're
+ // looking for a match in another file, which wasn't found.
+ // There will be an EMSG("file doesn't exist") below then.
if ((type == DT_NEXT || type == DT_FIRST)
&& nofile_fname == NULL) {
if (num_matches == 1) {
@@ -666,8 +665,8 @@ int do_tag(char_u *tag, int type, int count, int forceit, int verbose)
}
EMSG2(_("E429: File \"%s\" does not exist"), nofile_fname);
} else {
- /* We may have jumped to another window, check that
- * tagstackidx is still valid. */
+ // We may have jumped to another window, check that
+ // tagstackidx is still valid.
if (use_tagstack && tagstackidx > curwin->w_tagstacklen) {
tagstackidx = curwin->w_tagstackidx;
}
@@ -1584,15 +1583,15 @@ int find_tags(char_u *pat, int *num_matches, char_u ***matchesp, int flags, int
}
}
- /* When searching for a specific language skip tags files
- * for other languages. */
+ // When searching for a specific language skip tags files
+ // for other languages.
if (help_lang_find != NULL
&& STRICMP(help_lang, help_lang_find) != 0) {
continue;
}
- /* For CTRL-] in a help file prefer a match with the same
- * language. */
+ // For CTRL-] in a help file prefer a match with the same
+ // language.
if ((flags & TAG_KEEP_LANG)
&& help_lang_find == NULL
&& curbuf->b_fname != NULL
@@ -2234,8 +2233,8 @@ parse_line:
tagname_free(&tn);
}
- /* stop searching when already did a linear search, or when TAG_NOIC
- * used, and 'ignorecase' not set or already did case-ignore search */
+ // stop searching when already did a linear search, or when TAG_NOIC
+ // used, and 'ignorecase' not set or already did case-ignore search
if (stop_searching || linear || (!p_ic && noic) || orgpat.regmatch.rm_ic) {
break;
}
@@ -2367,8 +2366,8 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
}
if (tnp->tn_hf_idx >= tag_fnames.ga_len) {
- /* Not found in 'runtimepath', use 'helpfile', if it exists and
- * wasn't used yet, replacing "help.txt" with "tags". */
+ // Not found in 'runtimepath', use 'helpfile', if it exists and
+ // wasn't used yet, replacing "help.txt" with "tags".
if (tnp->tn_hf_idx > tag_fnames.ga_len || *p_hf == NUL) {
return FAIL;
}
@@ -2393,8 +2392,8 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
}
if (first) {
- /* Init. We make a copy of 'tags', because autocommands may change
- * the value without notifying us. */
+ // Init. We make a copy of 'tags', because autocommands may change
+ // the value without notifying us.
tnp->tn_tags = vim_strsave((*curbuf->b_p_tags != NUL)
? curbuf->b_p_tags : p_tags);
tnp->tn_np = tnp->tn_tags;
@@ -2431,8 +2430,8 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
(void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,");
r_ptr = vim_findfile_stopdir(buf);
- /* move the filename one char forward and truncate the
- * filepath with a NUL */
+ // move the filename one char forward and truncate the
+ // filepath with a NUL
filename = path_tail(buf);
STRMOVE(filename + 1, filename);
*filename++ = NUL;
@@ -2790,8 +2789,8 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
}
if (keep_help) {
- /* A :ta from a help file will keep the b_help flag set. For ":ptag"
- * we need to use the flag from the window where we came from. */
+ // A :ta from a help file will keep the b_help flag set. For ":ptag"
+ // we need to use the flag from the window where we came from.
if (l_g_do_tagpreview != 0) {
keep_help_flag = curwin_save->w_buffer->b_help;
} else {
@@ -2905,8 +2904,8 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
p_ic = save_p_ic; // -V519
p_scs = save_p_scs;
- /* A search command may have positioned the cursor beyond the end
- * of the line. May need to correct that here. */
+ // A search command may have positioned the cursor beyond the end
+ // of the line. May need to correct that here.
check_cursor();
} else {
const int save_secure = secure;
@@ -3128,9 +3127,8 @@ int expand_tags(int tagnames, char_u *pat, int *num_file, char_u ***file)
TAG_MANY, curbuf->b_ffname);
}
if (ret == OK && !tagnames) {
- /* Reorganize the tags for display and matching as strings of:
- * "<tagname>\0<kind>\0<filename>\0"
- */
+ // Reorganize the tags for display and matching as strings of:
+ // "<tagname>\0<kind>\0<filename>\0"
for (i = 0; i < *num_file; i++) {
size_t len;
@@ -3260,8 +3258,8 @@ int get_tags(list_T *list, char_u *pat, char_u *buf_fname)
char_u *s, *n;
int len;
- /* Add extra field as a dict entry. Fields are
- * separated by Tabs. */
+ // Add extra field as a dict entry. Fields are
+ // separated by Tabs.
n = p;
while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':') {
++p;
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 18587b9b2c..8c6ce63ade 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -705,6 +705,23 @@ func Test_vimgreptitle()
augroup! QfBufWinEnter
endfunc
+func Test_bufwinenter_once()
+ augroup QfBufWinEnter
+ au!
+ au BufWinEnter * let g:got_afile ..= 'got ' .. expand('<afile>')
+ augroup END
+ let g:got_afile = ''
+ copen
+ call assert_equal('got quickfix', g:got_afile)
+
+ cclose
+ unlet g:got_afile
+ augroup QfBufWinEnter
+ au!
+ augroup END
+ augroup! QfBufWinEnter
+endfunc
+
func XqfTitleTests(cchar)
call s:setup_commands(a:cchar)
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 5261f9e2ec..de396428a7 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -503,8 +503,8 @@ int u_savecommon(buf_T *buf, linenr_T top, linenr_T bot, linenr_T newbot, int re
break;
}
- /* If lines have been inserted/deleted we give up.
- * Also when the line was included in a multi-line save. */
+ // If lines have been inserted/deleted we give up.
+ // Also when the line was included in a multi-line save.
if ((buf->b_u_newhead->uh_getbot_entry != uep
? (uep->ue_top + uep->ue_size + 1
!= (uep->ue_bot == 0
@@ -520,18 +520,18 @@ int u_savecommon(buf_T *buf, linenr_T top, linenr_T bot, linenr_T newbot, int re
// If it's the same line we can skip saving it again.
if (uep->ue_size == 1 && uep->ue_top == top) {
if (i > 0) {
- /* It's not the last entry: get ue_bot for the last
- * entry now. Following deleted/inserted lines go to
- * the re-used entry. */
+ // It's not the last entry: get ue_bot for the last
+ // entry now. Following deleted/inserted lines go to
+ // the re-used entry.
u_getbot(buf);
buf->b_u_synced = false;
- /* Move the found entry to become the last entry. The
- * order of undo/redo doesn't matter for the entries
- * we move it over, since they don't change the line
- * count and don't include this line. It does matter
- * for the found entry if the line count is changed by
- * the executed command. */
+ // Move the found entry to become the last entry. The
+ // order of undo/redo doesn't matter for the entries
+ // we move it over, since they don't change the line
+ // count and don't include this line. It does matter
+ // for the found entry if the line count is changed by
+ // the executed command.
prev_uep->ue_next = uep->ue_next;
uep->ue_next = buf->b_u_newhead->uh_entry;
buf->b_u_newhead->uh_entry = uep;
@@ -1213,8 +1213,8 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf,
// Strip any sticky and executable bits.
perm = perm & 0666;
- /* If the undo file already exists, verify that it actually is an undo
- * file, and delete it. */
+ // If the undo file already exists, verify that it actually is an undo
+ // file, and delete it.
if (os_path_exists((char_u *)file_name)) {
if (name == NULL || !forceit) {
// Check we can read it and it's an undo file.
@@ -1254,8 +1254,8 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf,
os_remove(file_name);
}
- /* If there is no undo information at all, quit here after deleting any
- * existing undo file. */
+ // If there is no undo information at all, quit here after deleting any
+ // existing undo file.
if (buf->b_u_numhead == 0 && buf->b_u_line_ptr == NULL) {
if (p_verbose > 0) {
verb_msg(_("Skipping undo file write, nothing to undo"));
@@ -1883,10 +1883,10 @@ static void u_doit(int startcount, bool quiet, bool do_buf_event)
u_oldcount = -1;
}
while (count--) {
- /* Do the change warning now, so that it triggers FileChangedRO when
- * needed. This may cause the file to be reloaded, that must happen
- * before we do anything, because it may change curbuf->b_u_curhead
- * and more. */
+ // Do the change warning now, so that it triggers FileChangedRO when
+ // needed. This may cause the file to be reloaded, that must happen
+ // before we do anything, because it may change curbuf->b_u_curhead
+ // and more.
change_warning(curbuf, 0);
if (undo_undoes) {
@@ -1987,16 +1987,16 @@ void undo_time(long step, bool sec, bool file, bool absolute)
uhp = curbuf->b_u_newhead;
}
if (uhp != NULL && uhp->uh_save_nr != 0) {
- /* "uh_save_nr" was set in the last block, that means
- * there were no changes since the last write */
+ // "uh_save_nr" was set in the last block, that means
+ // there were no changes since the last write
target = curbuf->b_u_save_nr_cur + step;
} else {
// count the changes since the last write as one step
target = curbuf->b_u_save_nr_cur + step + 1;
}
if (target <= 0) {
- /* Go to before first write: before the oldest change. Use
- * the sequence number for that. */
+ // Go to before first write: before the oldest change. Use
+ // the sequence number for that.
dofile = false;
}
} else {
@@ -2047,11 +2047,11 @@ void undo_time(long step, bool sec, bool file, bool absolute)
* When using the closest time we use the sequence number in the second
* round, because there may be several entries with the same time.
*/
- for (round = 1; round <= 2; ++round) {
- /* Find the path from the current state to where we want to go. The
- * desired state can be anywhere in the undo tree, need to go all over
- * it. We put "nomark" in uh_walk where we have been without success,
- * "mark" where it could possibly be. */
+ for (round = 1; round <= 2; round++) {
+ // Find the path from the current state to where we want to go. The
+ // desired state can be anywhere in the undo tree, need to go all over
+ // it. We put "nomark" in uh_walk where we have been without success,
+ // "mark" where it could possibly be.
mark = ++lastmark;
nomark = ++lastmark;
@@ -2519,10 +2519,10 @@ static void u_undoredo(int undo, bool do_buf_event)
beginline(BL_SOL | BL_FIX);
}
} else {
- /* We get here with the current cursor line being past the end (eg
- * after adding lines at the end of the file, and then undoing it).
- * check_cursor() will move the cursor to the last line. Move it to
- * the first column here. */
+ // We get here with the current cursor line being past the end (eg
+ // after adding lines at the end of the file, and then undoing it).
+ // check_cursor() will move the cursor to the last line. Move it to
+ // the first column here.
curwin->w_cursor.col = 0;
curwin->w_cursor.coladd = 0;
}
@@ -2533,8 +2533,8 @@ static void u_undoredo(int undo, bool do_buf_event)
// Remember where we are for "g-" and ":earlier 10s".
curbuf->b_u_seq_cur = curhead->uh_seq;
if (undo) {
- /* We are below the previous undo. However, to make ":earlier 1s"
- * work we compute this as being just above the just undone change. */
+ // We are below the previous undo. However, to make ":earlier 1s"
+ // work we compute this as being just above the just undone change.
curbuf->b_u_seq_cur = curhead->uh_next.ptr ?
curhead->uh_next.ptr->uh_seq : 0;
}
diff --git a/src/nvim/window.c b/src/nvim/window.c
index dfe1ffdbd4..4a21c2eee5 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -464,9 +464,8 @@ wingotofile:
}
break;
- /* Go to the first occurrence of the identifier under cursor along path in a
- * new window -- webb
- */
+ // Go to the first occurrence of the identifier under cursor along path in a
+ // new window -- webb
case 'i': // Go to any match
case Ctrl_I:
type = FIND_ANY;
@@ -1046,8 +1045,8 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
win_setwidth_win(oldwin->w_width + new_size + 1, oldwin);
}
- /* Only make all windows the same width if one of them (except oldwin)
- * is wider than one of the split windows. */
+ // Only make all windows the same width if one of them (except oldwin)
+ // is wider than one of the split windows.
if (!do_equal && p_ea && size == 0 && *p_ead != 'v'
&& oldwin->w_frame->fr_parent != NULL) {
frp = oldwin->w_frame->fr_parent->fr_child;
@@ -1125,9 +1124,9 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
do_equal = true;
}
- /* We don't like to take lines for the new window from a
- * 'winfixheight' window. Take them from a window above or below
- * instead, if possible. */
+ // We don't like to take lines for the new window from a
+ // 'winfixheight' window. Take them from a window above or below
+ // instead, if possible.
if (oldwin->w_p_wfh) {
// Set w_fraction now so that the cursor keeps the same relative
// vertical position using the old height.
@@ -1142,8 +1141,8 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
}
}
- /* Only make all windows the same height if one of them (except oldwin)
- * is higher than one of the split windows. */
+ // Only make all windows the same height if one of them (except oldwin)
+ // is higher than one of the split windows.
if (!do_equal && p_ea && size == 0
&& *p_ead != 'h'
&& oldwin->w_frame->fr_parent != NULL) {
@@ -1874,15 +1873,14 @@ void win_move_after(win_T *win1, win_T *win2)
// check if there is something to do
if (win2->w_next != win1) {
- /* may need move the status line/vertical separator of the last window
- * */
+ // may need move the status line/vertical separator of the last window
if (win1 == lastwin) {
height = win1->w_prev->w_status_height;
win1->w_prev->w_status_height = win1->w_status_height;
win1->w_status_height = height;
if (win1->w_prev->w_vsep_width == 1) {
- /* Remove the vertical separator from the last-but-one window,
- * add it to the last window. Adjust the frame widths. */
+ // Remove the vertical separator from the last-but-one window,
+ // add it to the last window. Adjust the frame widths.
win1->w_prev->w_vsep_width = 0;
win1->w_prev->w_frame->fr_width -= 1;
win1->w_vsep_width = 1;
@@ -1974,8 +1972,8 @@ static void win_equal_rec(win_T *next_curwin, bool current, frame_T *topfr, int
topfr->fr_height = height;
if (dir != 'v') { // equalize frame widths
- /* Compute the maximum number of windows horizontally in this
- * frame. */
+ // Compute the maximum number of windows horizontally in this
+ // frame.
n = frame_minwidth(topfr, NOWIN);
// add one for the rightmost window, it doesn't have a separator
if (col + width == Columns) {
@@ -2360,8 +2358,8 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, tabpage_T *prev
char_u prev_idx[NUMBUFLEN];
sprintf((char *)prev_idx, "%i", tabpage_index(prev_curtab));
- /* Safety check: Autocommands may have closed the window when jumping
- * to the other tab page. */
+ // Safety check: Autocommands may have closed the window when jumping
+ // to the other tab page.
if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win) {
int h = tabline_height();
@@ -2421,15 +2419,15 @@ int win_close(win_T *win, bool free_buf)
return FAIL;
}
- /* When closing the last window in a tab page first go to another tab page
- * and then close the window and the tab page to avoid that curwin and
- * curtab are invalid while we are freeing memory. */
+ // When closing the last window in a tab page first go to another tab page
+ // and then close the window and the tab page to avoid that curwin and
+ // curtab are invalid while we are freeing memory.
if (close_last_window_tabpage(win, free_buf, prev_curtab)) {
return FAIL;
}
- /* When closing the help window, try restoring a snapshot after closing
- * the window. Otherwise clear the snapshot, it's now invalid. */
+ // When closing the help window, try restoring a snapshot after closing
+ // the window. Otherwise clear the snapshot, it's now invalid.
if (bt_help(win->w_buffer)) {
help_window = true;
} else {
@@ -2575,9 +2573,9 @@ int win_close(win_T *win, bool free_buf)
}
}
- /* Make sure curwin isn't invalid. It can cause severe trouble when
- * printing an error message. For win_equal() curbuf needs to be valid
- * too. */
+ // Make sure curwin isn't invalid. It can cause severe trouble when
+ // printing an error message. For win_equal() curbuf needs to be valid
+ // too.
if (win == curwin) {
curwin = wp;
if (wp->w_p_pvw || bt_quickfix(wp->w_buffer)) {
@@ -2895,9 +2893,9 @@ win_T *winframe_remove(win_T *win, int *dirp, tabpage_T *tp)
frp2 == frp_close->fr_next, false);
*dirp = 'v';
} else {
- /* When 'winfixwidth' is set, try to find another frame in the column
- * (as close to the closed frame as possible) to distribute the width
- * to. */
+ // When 'winfixwidth' is set, try to find another frame in the column
+ // (as close to the closed frame as possible) to distribute the width
+ // to.
if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfw) {
frp = frp_close->fr_prev;
frp3 = frp_close->fr_next;
@@ -3112,8 +3110,8 @@ static void frame_new_height(frame_T *topfrp, int height, bool topfirst, bool wf
}
} while (frp != NULL);
} else { // fr_layout == FR_COL
- /* Complicated case: Resize a column of frames. Resize the bottom
- * frame first, frames above that when needed. */
+ // Complicated case: Resize a column of frames. Resize the bottom
+ // frame first, frames above that when needed.
frp = topfrp->fr_child;
if (wfh) {
@@ -3310,8 +3308,8 @@ static void frame_new_width(frame_T *topfrp, int width, bool leftfirst, bool wfw
}
} while (frp != NULL);
} else { // fr_layout == FR_ROW
- /* Complicated case: Resize a row of frames. Resize the rightmost
- * frame first, frames left of it when needed. */
+ // Complicated case: Resize a row of frames. Resize the rightmost
+ // frame first, frames left of it when needed.
frp = topfrp->fr_child;
if (wfw) {
@@ -4043,8 +4041,8 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, bool trigger_enter_a
lastused_tabpage = old_curtab;
- /* Apply autocommands after updating the display, when 'rows' and
- * 'columns' have been set correctly. */
+ // Apply autocommands after updating the display, when 'rows' and
+ // 'columns' have been set correctly.
if (trigger_enter_autocmds) {
apply_autocmds(EVENT_TABENTER, NULL, NULL, false, curbuf);
if (old_curbuf != curbuf) {
@@ -4776,8 +4774,8 @@ static void win_free(win_T *wp, tabpage_T *tp)
xfree(wp->w_localdir);
xfree(wp->w_prevdir);
- /* Remove the window from the b_wininfo lists, it may happen that the
- * freed memory is re-used for another window. */
+ // Remove the window from the b_wininfo lists, it may happen that the
+ // freed memory is re-used for another window.
FOR_ALL_BUFFERS(buf) {
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) {
if (wip->wi_win == wp) {
@@ -4950,8 +4948,8 @@ void shell_new_rows(void)
h = frame_minheight(topframe, NULL);
}
- /* First try setting the heights of windows with 'winfixheight'. If
- * that doesn't result in the right height, forget about that option. */
+ // First try setting the heights of windows with 'winfixheight'. If
+ // that doesn't result in the right height, forget about that option.
frame_new_height(topframe, h, false, true);
if (!frame_check_height(topframe, h)) {
frame_new_height(topframe, h, false, false);
@@ -4972,8 +4970,8 @@ void shell_new_columns(void)
return;
}
- /* First try setting the widths of windows with 'winfixwidth'. If that
- * doesn't result in the right width, forget about that option. */
+ // First try setting the widths of windows with 'winfixwidth'. If that
+ // doesn't result in the right width, forget about that option.
frame_new_width(topframe, Columns, false, true);
if (!frame_check_width(topframe, Columns)) {
frame_new_width(topframe, Columns, false, false);
@@ -5572,8 +5570,8 @@ void win_drag_status_line(win_T *dragwin, int offset)
}
}
- /* If this is the last frame in a column, may want to resize the parent
- * frame instead (go two up to skip a row of frames). */
+ // If this is the last frame in a column, may want to resize the parent
+ // frame instead (go two up to skip a row of frames).
while (curfr != topframe && curfr->fr_next == NULL) {
if (fr != topframe) {
fr = fr->fr_parent;
@@ -5699,8 +5697,8 @@ void win_drag_vsep_line(win_T *dragwin, int offset)
fr = fr->fr_parent;
}
- /* If this is the last frame in a row, may want to resize a parent
- * frame instead. */
+ // If this is the last frame in a row, may want to resize a parent
+ // frame instead.
while (curfr->fr_next == NULL) {
if (fr == topframe) {
break;
diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua
index 0675ec9abd..ab76e71a12 100644
--- a/test/functional/lua/luaeval_spec.lua
+++ b/test/functional/lua/luaeval_spec.lua
@@ -527,6 +527,12 @@ describe('v:lua', function()
]]}
end)
+ it('supports packages', function()
+ command('set pp+=test/functional/fixtures')
+ eq('\tbadval', eval("v:lua.require'leftpad'('badval')"))
+ eq(9003, eval("v:lua.require'bar'.doit()"))
+ end)
+
it('throw errors for invalid use', function()
eq('Vim(let):E15: Invalid expression: v:lua.func', pcall_err(command, "let g:Func = v:lua.func"))
eq('Vim(let):E15: Invalid expression: v:lua', pcall_err(command, "let g:Func = v:lua"))
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 8074f91215..40c33d9a4d 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -901,15 +901,15 @@ if (h->n_buckets < new_n_buckets) { // expand
screen:expect{grid=[[
if (h->n_buckets < new_n_buckets) { // expand |
khkey_t *new_keys = (khkey_t *) |
+ {1:>> }{2:krealloc}: change the size of an allocation |
{3:krealloc}((void *)h->keys, new_n_buckets * sizeof(k|
hkey_t)); |
h->keys = new_keys; |
if (kh_is_map && val_size) { |
- char *new_vals = {3:krealloc}( h->vals_buf, new_n_|
- buck^ets * val_size); |
+ ^char *new_vals = {3:krealloc}( h->vals_buf, new_n_|
+ buckets * val_size); |
{5:^^ REVIEW:}{6: new_vals variable seems unneccesary?} |
h->vals_buf = new_vals; |
- } |
|
]]}
@@ -1235,6 +1235,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
]]}
+ meths.buf_clear_namespace(0, ns, 0, -1)
meths.buf_set_extmark(0, ns, 2, 0, {
virt_lines={
{{"Some special", "Special"}};
diff --git a/test/unit/marktree_spec.lua b/test/unit/marktree_spec.lua
index cd9c7bef13..10d02d2eb4 100644
--- a/test/unit/marktree_spec.lua
+++ b/test/unit/marktree_spec.lua
@@ -97,7 +97,7 @@ describe('marktree', function()
for i = 1,100 do
for j = 1,100 do
local gravitate = (i%2) > 0
- local id = tonumber(lib.marktree_put(tree, j, i, gravitate))
+ local id = tonumber(lib.marktree_put(tree, j, i, gravitate, 0))
ok(id > 0)
eq(nil, shadow[id])
shadow[id] = {j,i,gravitate}
@@ -191,7 +191,7 @@ describe('marktree', function()
-- https://github.com/neovim/neovim/pull/14719
lib.marktree_clear(tree)
for i = 1,20 do
- lib.marktree_put(tree, i, i, false)
+ lib.marktree_put(tree, i, i, false, 0)
end
lib.marktree_itr_get(tree, 10, 10, iter)