Expand git-config filename pattern to include */git/config#4025
Expand git-config filename pattern to include */git/config#4025injust wants to merge 2 commits intomicro-editor:masterfrom
*/git/config#4025Conversation
foo/git/config*/git/config
JoeKar
left a comment
There was a problem hiding this comment.
@Andriamanitra
Do you see something I didn't?
|
|
||
| detect: | ||
| filename: "git(config|modules)$|\\.git/config$" | ||
| filename: "git(config|modules)$|^(.*[\\/])?\\.?git[\\/]config$" |
There was a problem hiding this comment.
I think you need more backslashes if [\\/] is supposed to match both regular and windows-style path separators...
| filename: "git(config|modules)$|^(.*[\\/])?\\.?git[\\/]config$" | |
| filename: "git(config|modules)$|^(.*[\\\\/])?\\.?git[\\\\/]config$" |
There was a problem hiding this comment.
In [\\/], I'm not sure if the backslash is treated as an escape character. But what I have now is consistent with the rest of the syntax highlighting files.
But we should really change all these strings to single-quoted strings to avoid all the backslashes.
There was a problem hiding this comment.
There was a problem hiding this comment.
In
[\\/], I'm not sure if the backslash is treated as an escape character.
In YAML the content of "[\\/]" already results in a interpret string of [\/] used by regexp due to its presence within []. Only the representation of the same string written in Go needs to be "[\\\\/]".
So I'd assume that the current state should work.
There was a problem hiding this comment.
Did you test it? At least on my machine it wouldn't recognize git\config without the extra backslashes. I'm on Linux so the \ is a part of the filename rather than a path separator but I believe the path matching should work the same regardless of how the OS treats it.
The double-quoted string in yaml eats the first escape so the regex just sees [\/], which it interprets as "character group with a literal / in it" (/ doesn't require escaping but it's still treated as an escape sequence).
There was a problem hiding this comment.
Damn, looks you're right. I tried it now too...sorry for that.
This means, that the same check in git-commit.yaml, git-rebase-todo.yaml and ruby.yaml doesn't work either.
There was a problem hiding this comment.
Damn, looks you're right. I tried it now too...sorry for that. This means, that the same check in
git-commit.yaml,git-rebase-todo.yamlandruby.yamldoesn't work either.
What makes me wonder is that it didn't work the easy (single-escaped) way, when I used single-quotes for the YAML string. 🤔
There was a problem hiding this comment.
What makes me wonder is that it didn't work the easy (single-escaped) way, when I used single-quotes for the YAML string. 🤔
[\\/] should work with single-quoted string. Maybe you forgot to change the \\. to \.?
There was a problem hiding this comment.
Maybe you forgot to change the
\\.to\.?
Exactly, this was the case. 👍
But we should really change all these strings to single-quoted strings to avoid all the backslashes.
I agree, this would really help to simplify all of the regex strings...especially the ones where we used \\\\. and all of this double backslash escaping.
micro currently doesn't highlight
~/.config/git/configbecause the filename pattern requires the directory to be named.git/(with a dot).Related to #3962