repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fix(cmdline): require word boundary after lua in format detection

6c3beb521f55916d9c8ae9729ad656a59eecac08

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Pattern ^lua%s* was too loose - it matched luafile and luado.
Fix to require either lua followed by whitespace, lua alone, or =.

Changed files (2)

neovim/lua/bugabinga/cmdline/format.lua

Modified
32 32 return { type = 'help', icon = icon.help, lang = nil }
35 - if content:match '^lua%s*' or content:match '^=' then
35 + if content:match '^lua%s' or content:match '^lua$' or content:match '^=' then
36 36 return { type = 'lua', icon = icon.vim, lang = 'lua' }
38 38 return { type = 'cmdline', icon = icon.command, lang = 'vim' }

neovim/tests/bugabinga/cmdline/format_spec.lua

Modified
85 85 assert.equals('', result.icon)
88 + it('does not detect :luafile as lua', function()
89 + local result = format.detect(':', 'luafile', '')
90 + assert.equals('cmdline', result.type)
91 + end)
93 + it('does not detect :luado as lua', function()
94 + local result = format.detect(':', 'luado', '')
95 + assert.equals('cmdline', result.type)
96 + end)
88 98 it('detects input when prompt is non-empty', function()
89 99 local result = format.detect(':', 'some input', 'Enter name: ')
90 100 assert.equals('input', result.type)