vim-patch:9.1.0731: inconsistent case sensitive extension matching

Problem:  inconsistent case sensitive extension matching
Solution: unify case sensitive extension matching (Evgeni Chasnovski).

There are different approaches of how extensions are matched with
respect to case sensitivity. In particular, '\c' flag is used in pattern
whereas in most places case sensitive matching is guarded behind
`has("fname_case")` condition.

Replace all instances of '\c' with an explicit case sensitive pattern
variants guarded by `has("fname_case")`. Strictly speaking, this is a
breaking change because only two (most common and prevailingly tested)
variants are now matched: upper first letter and upper all letters.

closes: vim/vim#15672

59b089c9df

Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
This commit is contained in:
Christian Clason 2024-09-15 19:32:19 +02:00
parent 78b8510933
commit f408603f4f
2 changed files with 7 additions and 48 deletions

View File

@ -280,12 +280,7 @@ local extension = {
cfi = 'cf',
hgrc = 'cfg',
cfg = detect.cfg,
cfG = detect.cfg,
cFg = detect.cfg,
cFG = detect.cfg,
Cfg = detect.cfg,
CfG = detect.cfg,
CFg = detect.cfg,
CFG = detect.cfg,
chf = 'ch',
chai = 'chaiscript',
@ -370,12 +365,7 @@ local extension = {
drt = 'dart',
ds = 'datascript',
dat = detect.dat,
daT = detect.dat,
dAt = detect.dat,
dAT = detect.dat,
Dat = detect.dat,
DaT = detect.dat,
DAt = detect.dat,
DAT = detect.dat,
dcd = 'dcd',
decl = detect.decl,
@ -658,12 +648,7 @@ local extension = {
kt = 'kotlin',
ktm = 'kotlin',
sub = 'krl',
suB = 'krl',
sUb = 'krl',
sUB = 'krl',
Sub = 'krl',
SuB = 'krl',
SUb = 'krl',
SUB = 'krl',
ks = 'kscript',
k = 'kwt',
@ -699,12 +684,7 @@ local extension = {
lite = 'lite',
livemd = 'livebook',
log = detect.log,
loG = detect.log,
lOg = detect.log,
lOG = detect.log,
Log = detect.log,
LoG = detect.log,
LOg = detect.log,
LOG = detect.log,
lgt = 'logtalk',
lotos = 'lotos',
@ -773,12 +753,7 @@ local extension = {
mmp = 'mmp',
mms = detect.mms,
mod = detect.mod,
moD = detect.mod,
mOd = detect.mod,
mOD = detect.mod,
Mod = detect.mod,
MoD = detect.mod,
MOd = detect.mod,
MOD = detect.mod,
DEF = 'modula2',
m3 = 'modula3',
@ -948,12 +923,7 @@ local extension = {
ih = 'ppwiz',
action = 'privoxy',
prg = detect.prg,
prG = detect.prg,
pRg = detect.prg,
pRG = detect.prg,
Prg = detect.prg,
PrG = detect.prg,
PRg = detect.prg,
PRG = detect.prg,
pc = 'proc',
pdb = 'prolog',
@ -1133,12 +1103,7 @@ local extension = {
sqr = 'sqr',
nut = 'squirrel',
src = detect.src,
srC = detect.src,
sRc = detect.src,
sRC = detect.src,
Src = detect.src,
SrC = detect.src,
SRc = detect.src,
SRC = detect.src,
s28 = 'srec',
s37 = 'srec',
@ -1168,12 +1133,7 @@ local extension = {
swig = 'swig',
swg = 'swig',
sys = detect.sys,
syS = detect.sys,
sYs = detect.sys,
sYS = detect.sys,
Sys = detect.sys,
SyS = detect.sys,
SYs = detect.sys,
SYS = detect.sys,
svh = 'systemverilog',
sv = 'systemverilog',

View File

@ -1150,15 +1150,14 @@ func Test_cfg_file()
unlet g:filetype_cfg
" RAPID cfg
let ext = 'cfg'
for i in ['EIO', 'MMC', 'MOC', 'PROC', 'SIO', 'SYS']
for ext in ['cfg', 'Cfg', 'CFG']
call writefile([i .. ':CFG'], 'cfgfile.' .. ext)
execute "split cfgfile." .. ext
call assert_equal('rapid', &filetype)
bwipe!
call delete('cfgfile.' .. ext)
" check different case of file extension
let ext = substitute(ext, '\(\l\)', '\u\1', '')
endfor
endfor
" clean up