view runtime/syntax/cdl.vim @ 34416:0a458b49e1e6 v9.1.0131

patch 9.1.0131: buffer-completion may not always find all matches Commit: https://github.com/vim/vim/commit/0dc0bff000fd804c6b0778ccc4554a4e4c82c8c9 Author: Christian Brabandt <cb@256bit.org> Date: Sat Feb 24 14:12:13 2024 +0100 patch 9.1.0131: buffer-completion may not always find all matches Problem: buffer-completion code too complicated and does not always find all matches (irisjae) Solution: do not try to anchor pattern to beginning of line or directory-separator, always return all matches Note: we are considering the non-fuzzy buffer-matching here. Currently, the buffer-completion code makes 2 attempts to match a pattern against the list of available patterns. First try is to match the pattern and anchor it to either the beginning of the file name or at a directory-separator (// or \\). When a match is found, Vim returns the matching buffers and does not try to find a match anywhere within a buffer name. So if you have opened two buffers like /tmp/Foobar.c and /tmp/MyFoobar.c using `:b Foo` will only complete to the first filename, but not the second (the same happens with `getcompletion('Foo', 'buffer')`). It may make sense, that completion priorities buffer names at directory boundaries, but it inconsistent, may cause confusion why a certain buffer name is not completed when typing `:b Foo<C-D>` which returns only a single file name and then pressing Enter (to switch to that buffer), Vim will error with 'E93: More than one match for Foo'). Similar things may happen when wiping the /tmp/Foobar.c pattern and afterwards the completion starts completing other buffers. So let's simplify the code and always match the pattern anywhere in the buffer name, do not try to favor matches at directory boundaries. This is also simplifies the code a bit, we do not need to run over the list of buffers several times, but only twice. fixes #13894 closes: #14082 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 24 Feb 2024 14:30:03 +0100
parents 584c835a2de1
children
line wrap: on
line source

" Vim syntax file
" Language: Comshare Dimension Definition Language
" Maintainer:	Raul Segura Acevedo <raulseguraaceved@netscape.net>
" Last change:	2016 Sep 20

" quit when a syntax file was already loaded
if exists("b:current_syntax")
	finish
endif

sy case ignore
sy sync fromstart
sy keyword	cdlStatement	dimension hierarchy group grouphierarchy schedule class
sy keyword	cdlType		add update file category main altername removeall required notrequired
sy keyword	cdlConditional	if then elseif else endif and or not cons rpt xlt
sy keyword	cdlFunction	ChildOf IChildOf LeafChildOf DescendantOf IDescendantOf LeafDescendantOf MemberIs CountOf

sy keyword	cdlIdentifier	contained id name desc description xlttype precision symbol curr_ name group_name rate_name
sy keyword	cdlIdentifier	contained xcheck endbal accounttype natsign consolidate formula pctown usage periodicity
sy match	cdlIdentifier	contained 'child\s*name'
sy match	cdlIdentifier	contained 'parent\s*name'
sy match	cdlIdentifier	contained 'grp\s*description'
sy match	cdlIdentifier	contained 'grpchild\s*name'
sy match	cdlIdentifier	contained 'grpparent\s*name'
sy match	cdlIdentifier	contained 'preceding\s*member'
sy match	cdlIdentifier	contained 'unit\s*name'
sy match	cdlIdentifier	contained 'unit\s*id'
sy match	cdlIdentifier	contained 'schedule\s*name'
sy match	cdlIdentifier	contained 'schedule\s*id'

sy match	cdlString	/\[[^]]*]/	contains=cdlRestricted,cdlNotSupported
sy match	cdlRestricted	contained /[&*,_]/
" not supported
sy match	cdlNotSupported	contained /[:"!']/

sy keyword	cdlTodo		contained TODO FIXME XXX
sy cluster	cdlCommentGroup contains=cdlTodo
sy match	cdlComment	'//.*' contains=@cdlCommentGroup
sy region	cdlComment	start="/\*" end="\*/" contains=@cdlCommentGroup fold
sy match	cdlCommentE	"\*/"

sy region	cdlParen	transparent start='(' end=')' contains=ALLBUT,cdlParenE,cdlRestricted,cdlNotSupported
"sy region	cdlParen	transparent start='(' end=')' contains=cdlIdentifier,cdlComment,cdlParenWordE
sy match	cdlParenE	")"
"sy match	cdlParenWordE	contained "\k\+"

sy keyword	cdlFxType	allocation downfoot expr xltgain
"sy keyword	cdlFxType	contained allocation downfoot expr xltgain
"sy region	cdlFx		transparent start='\k\+(' end=')' contains=cdlConditional,cdlFunction,cdlString,cdlComment,cdlFxType

set foldmethod=expr
set foldexpr=(getline(v:lnum+1)=~'{'\|\|getline(v:lnum)=~'//\\s\\*\\{5}.*table')?'>1':1
%foldo!
set foldmethod=manual
let b:match_words='\<if\>:\<then\>:\<elseif\>:\<else\>:\<endif\>'

" Define the default highlighting.
" Only when an item doesn't have highlighting yet

hi def link cdlStatement	Statement
hi def link cdlType		Type
hi def link cdlFxType	Type
hi def link cdlIdentifier	Identifier
hi def link cdlString	String
hi def link cdlRestricted	WarningMsg
hi def link cdlNotSupported	ErrorMsg
hi def link cdlTodo		Todo
hi def link cdlComment	Comment
hi def link cdlCommentE	ErrorMsg
hi def link cdlParenE	ErrorMsg
hi def link cdlParenWordE	ErrorMsg
hi def link cdlFunction	Function
hi def link cdlConditional	Conditional


let b:current_syntax = "cdl"

" vim: ts=8