mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 12:28:18 +00:00
fix(editorconfig): a custom property is treated as a section (#34445)
Problem: A custom property containing a pair of square brackets will be
treated as a section.
Solution: Change the logic parsing a section, remove the first match
regex `%b[]`.
Signed-off-by: fortime <palfortime@gmail.com>
(cherry picked from commit 966b1da183
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
0f1cada0f7
commit
902c946bcd
@@ -245,7 +245,7 @@ local function parse_line(line)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @type string?
|
--- @type string?
|
||||||
local glob = (line:match('%b[]') or ''):match('^%s*%[(.*)%]%s*$')
|
local glob = line:match('^%s*%[(.*)%]%s*$')
|
||||||
if glob then
|
if glob then
|
||||||
return glob
|
return glob
|
||||||
end
|
end
|
||||||
|
@@ -106,6 +106,10 @@ setup(function()
|
|||||||
|
|
||||||
[long_spelling_language.txt]
|
[long_spelling_language.txt]
|
||||||
spelling_language = en-NZ
|
spelling_language = en-NZ
|
||||||
|
|
||||||
|
[custom_properties.txt]
|
||||||
|
property1 = something1
|
||||||
|
property2 = x[something2]x
|
||||||
]]
|
]]
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
@@ -240,4 +244,20 @@ But not this one
|
|||||||
test_case('short_spelling_language.txt', { spelllang = 'de' })
|
test_case('short_spelling_language.txt', { spelllang = 'de' })
|
||||||
test_case('long_spelling_language.txt', { spelllang = 'en_nz' })
|
test_case('long_spelling_language.txt', { spelllang = 'en_nz' })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('set custom properties', function()
|
||||||
|
n.exec_lua(function()
|
||||||
|
local editorconfig = require('editorconfig')
|
||||||
|
editorconfig.properties.property1 = function(bufnr, val, _opts)
|
||||||
|
vim.b[bufnr].property1 = val
|
||||||
|
end
|
||||||
|
editorconfig.properties.property2 = function(bufnr, val, _opts)
|
||||||
|
vim.b[bufnr].property2 = val
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
command('edit ' .. testdir .. pathsep .. 'custom_properties.txt')
|
||||||
|
eq('something1', fn.luaeval('vim.b.property1'), 'property1')
|
||||||
|
eq('x[something2]x', fn.luaeval('vim.b.property2'), 'property2')
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user