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', cfi = 'cf',
hgrc = 'cfg', 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,
CFg = detect.cfg,
CFG = detect.cfg, CFG = detect.cfg,
chf = 'ch', chf = 'ch',
chai = 'chaiscript', chai = 'chaiscript',
@ -370,12 +365,7 @@ local extension = {
drt = 'dart', drt = 'dart',
ds = 'datascript', 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,
DAt = detect.dat,
DAT = detect.dat, DAT = detect.dat,
dcd = 'dcd', dcd = 'dcd',
decl = detect.decl, decl = detect.decl,
@ -658,12 +648,7 @@ local extension = {
kt = 'kotlin', kt = 'kotlin',
ktm = 'kotlin', ktm = 'kotlin',
sub = 'krl', sub = 'krl',
suB = 'krl',
sUb = 'krl',
sUB = 'krl',
Sub = 'krl', Sub = 'krl',
SuB = 'krl',
SUb = 'krl',
SUB = 'krl', SUB = 'krl',
ks = 'kscript', ks = 'kscript',
k = 'kwt', k = 'kwt',
@ -699,12 +684,7 @@ local extension = {
lite = 'lite', lite = 'lite',
livemd = 'livebook', 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,
LOg = detect.log,
LOG = detect.log, LOG = detect.log,
lgt = 'logtalk', lgt = 'logtalk',
lotos = 'lotos', lotos = 'lotos',
@ -773,12 +753,7 @@ local extension = {
mmp = 'mmp', mmp = 'mmp',
mms = detect.mms, 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,
MOd = detect.mod,
MOD = detect.mod, MOD = detect.mod,
DEF = 'modula2', DEF = 'modula2',
m3 = 'modula3', m3 = 'modula3',
@ -948,12 +923,7 @@ local extension = {
ih = 'ppwiz', ih = 'ppwiz',
action = 'privoxy', 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,
PRg = detect.prg,
PRG = detect.prg, PRG = detect.prg,
pc = 'proc', pc = 'proc',
pdb = 'prolog', pdb = 'prolog',
@ -1133,12 +1103,7 @@ local extension = {
sqr = 'sqr', sqr = 'sqr',
nut = 'squirrel', 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,
SRc = detect.src,
SRC = detect.src, SRC = detect.src,
s28 = 'srec', s28 = 'srec',
s37 = 'srec', s37 = 'srec',
@ -1168,12 +1133,7 @@ local extension = {
swig = 'swig', swig = 'swig',
swg = '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,
SYs = detect.sys,
SYS = detect.sys, SYS = detect.sys,
svh = 'systemverilog', svh = 'systemverilog',
sv = 'systemverilog', sv = 'systemverilog',

View File

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