view runtime/syntax/teraterm.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 34fd018452ed
children
line wrap: on
line source

" Vim syntax file
" Language:	Tera Term Language (TTL)
"		Based on Tera Term Version 4.100
" Maintainer:	Ken Takata
" URL:		https://github.com/k-takata/vim-teraterm
" Last Change:	2018-08-31
" Filenames:	*.ttl
" License:	VIM License

if exists("b:current_syntax")
  finish
endif

let s:save_cpo = &cpo
set cpo&vim

syn case ignore

syn region ttlComment	start=";" end="$" contains=@Spell
syn region ttlComment	start="/\*" end="\*/" contains=@Spell
syn region ttlFirstComment	start="/\*" end="\*/" contained contains=@Spell
			\ nextgroup=ttlStatement,ttlFirstComment

syn match ttlCharacter	"#\%(\d\+\|\$\x\+\)\>"
syn match ttlNumber	"\%(\<\d\+\|\$\x\+\)\>"
syn match ttlString	"'[^']*'" contains=@Spell
syn match ttlString	'"[^"]*"' contains=@Spell
syn cluster ttlConstant contains=ttlCharacter,ttlNumber,ttlString

syn match ttlLabel	":\s*\w\{1,32}\>"

syn keyword ttlOperator	and or xor not

syn match ttlVar	"\<groupmatchstr\d\>"
syn match ttlVar	"\<param\d\>"
syn keyword ttlVar	inputstr matchstr paramcnt params result timeout mtimeout


syn match ttlLine nextgroup=ttlStatement "^"
syn match ttlStatement contained "\s*"
			\ nextgroup=ttlIf,ttlElseIf,ttlConditional,ttlRepeat,
			\ ttlFirstComment,ttlComment,ttlLabel,@ttlCommand

syn cluster ttlCommand contains=ttlControlCommand,ttlCommunicationCommand,
			\ ttlStringCommand,ttlFileCommand,ttlPasswordCommand,
			\ ttlMiscCommand


syn keyword ttlIf contained nextgroup=ttlIfExpression if
syn keyword ttlElseIf contained nextgroup=ttlElseIfExpression elseif

syn match ttlIfExpression contained "\s.*"
		\ contains=@ttlConstant,ttlVar,ttlOperator,ttlComment,ttlThen,
		\ @ttlCommand
syn match ttlElseIfExpression contained "\s.*"
		\ contains=@ttlConstant,ttlVar,ttlOperator,ttlComment,ttlThen

syn keyword ttlThen contained then
syn keyword ttlConditional contained else endif

syn keyword ttlRepeat contained for next until enduntil while endwhile
syn match ttlRepeat contained
			\ "\<\%(do\|loop\)\%(\s\+\%(while\|until\)\)\?\>"
syn keyword ttlControlCommand contained
			\ break call continue end execcmnd exit goto include
			\ mpause pause return


syn keyword ttlCommunicationCommand contained
			\ bplusrecv bplussend callmenu changedir clearscreen
			\ closett connect cygconnect disconnect dispstr
			\ enablekeyb flushrecv gethostname getmodemstatus
			\ gettitle kmtfinish kmtget kmtrecv kmtsend loadkeymap
			\ logautoclosemode logclose loginfo logopen logpause
			\ logrotate logstart logwrite quickvanrecv
			\ quickvansend recvln restoresetup scprecv scpsend
			\ send sendbreak sendbroadcast sendfile sendkcode
			\ sendln sendlnbroadcast sendlnmulticast sendmulticast
			\ setbaud setdebug setdtr setecho setflowctrl
			\ setmulticastname setrts setspeed setsync settitle
			\ showtt testlink unlink wait wait4all waitevent
			\ waitln waitn waitrecv waitregex xmodemrecv
			\ xmodemsend ymodemrecv ymodemsend zmodemrecv
			\ zmodemsend
syn keyword ttlStringCommand contained
			\ code2str expandenv int2str regexoption sprintf
			\ sprintf2 str2code str2int strcompare strconcat
			\ strcopy strinsert strjoin strlen strmatch strremove
			\ strreplace strscan strspecial strsplit strtrim
			\ tolower toupper
syn keyword ttlFileCommand contained
			\ basename dirname fileclose fileconcat filecopy
			\ filecreate filedelete filelock filemarkptr fileopen
			\ filereadln fileread filerename filesearch fileseek
			\ fileseekback filestat filestrseek filestrseek2
			\ filetruncate fileunlock filewrite filewriteln
			\ findfirst findnext findclose foldercreate
			\ folderdelete foldersearch getdir getfileattr makepath
			\ setdir setfileattr
syn keyword ttlPasswordCommand contained
			\ delpassword getpassword ispassword passwordbox
			\ setpassword
syn keyword ttlMiscCommand contained
			\ beep bringupbox checksum8 checksum8file checksum16
			\ checksum16file checksum32 checksum32file closesbox
			\ clipb2var crc16 crc16file crc32 crc32file exec
			\ dirnamebox filenamebox getdate getenv getipv4addr
			\ getipv6addr getspecialfolder gettime getttdir getver
			\ ifdefined inputbox intdim listbox messagebox random
			\ rotateleft rotateright setdate setdlgpos setenv
			\ setexitcode settime show statusbox strdim uptime
			\ var2clipb yesnobox


hi def link ttlCharacter Character
hi def link ttlNumber Number
hi def link ttlComment Comment
hi def link ttlFirstComment Comment
hi def link ttlString String
hi def link ttlLabel Label
hi def link ttlIf Conditional
hi def link ttlElseIf Conditional
hi def link ttlThen Conditional
hi def link ttlConditional Conditional
hi def link ttlRepeat Repeat
hi def link ttlControlCommand Keyword
hi def link ttlVar Identifier
hi def link ttlOperator Operator
hi def link ttlCommunicationCommand Keyword
hi def link ttlStringCommand Keyword
hi def link ttlFileCommand Keyword
hi def link ttlPasswordCommand Keyword
hi def link ttlMiscCommand Keyword

let b:current_syntax = "teraterm"

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: ts=8 sw=2 sts=2