tpope / vim-sleuth

sleuth.vim: Heuristically set buffer options
https://www.vim.org/scripts/script.php?script_id=4375
1.92k stars 86 forks source link

`.editorconfig` file with multiple extensions picks wrong settings #96

Closed keith closed 1 month ago

keith commented 1 month ago

With this .editorconfig file:

[*]
indent_size = 2

[*.{py,js}]
indent_size = 4

When I edit foo.py, shiftwidth is set to 2 instead of 4. I verified that adding [*.py] instead works correctly.

I bisected and this was broken by https://github.com/tpope/vim-sleuth/commit/cd9d382e33bb817abe7f10cdc3a606bf1d491d75

I added some logging here: https://github.com/tpope/vim-sleuth/blob/cd9d382e33bb817abe7f10cdc3a606bf1d491d75/plugin/sleuth.vim#L263 like this:

      echom "pattern " . pattern
      echom "translated: " . s:FnmatchTranslate(pattern)

and found that in the [*.py] case you get:

pattern /**/*.py
translated: /.*\.py

But in the [*.{py,js}] case you get:

pattern /**/*.{py,js}
translated: /.*\.\%(\|\|\|\|\|\|\|\)
keith commented 1 month ago

I've submitted an attempted fix for this https://github.com/tpope/vim-sleuth/pull/97 but it's very possible I'm missing some edge cases in the regex

keith commented 1 month ago

Thanks!