-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bat language coloring detection seems to be case sensitive on Windows #2520
Comments
Hello ! I have reproduced the bug on Windows and I can confirm the After digging through the code in pub fn insert(&mut self, from: &str, to: MappingTarget<'a>) -> Result<()> {
let glob = GlobBuilder::new(from)
.case_insensitive(false)
.literal_separator(true)
.build()?;
self.mappings.push((glob.compile_matcher(), to));
Ok(())
} This toggles the boolean value in Ok(Glob {
glob: self.glob.to_string(),
re: tokens.to_regex_with(&self.opts),
opts: self.opts,
tokens: tokens,
}) fn to_regex_with(&self, options: &GlobOptions) -> String {
let mut re = String::new();
re.push_str("(?-u)");
if options.case_insensitive {
re.push_str("(?i)");
}
re.push('^');
// Special case. If the entire glob is just `**`, then it should match
// everything.
if self.len() == 1 && self[0] == Token::RecursivePrefix {
re.push_str(".*");
re.push('$');
return re;
}
self.tokens_to_regex(options, &self, &mut re);
re.push('$');
re
} A first approach to fix this would be to simply change the default behavior to be If this is not possible due to some matching needing case sensitivity, it would require to add a an option which needs to be picked up in the config file to tell if a matching rule needs to be case insensitive. I have implemented the first one and tested it on Windows: it works as expected. I ran all tests and integration tests which all passed: I didn't see how I could add one for the specific change though. I will open a pull request with that change if there is no need to catter to specific case sensitive mapping. |
the PR fixing this was merged a while ago, so I think this can be safely closed :) |
I have a nuget config file, named NuGet.Config.
I also have the
.config
extension mapped to XML in my bat config file:--map-syntax='*.config:XML'
With the command
bat NuGet.Config
, no coloring is displayed.With the command
bat NuGet.config
, coloring is displayed.If I rename the file so that the extension is lowercase (
NuGet.config
), the color/nocolor behavior is the same:With the command
bat NuGet.Config
, no coloring is displayed.With the command
bat NuGet.config
, coloring is displayed.What steps will reproduce the bug?
What happens?
The file is displayed without syntax coloring.
What did you expect to happen instead?
The file is displayed with syntax coloring.
How did you install
bat
?chocolatey
bat version and environment
Software version
bat 0.22.1 (e5d9579)
Operating system
Windows 6.2.9200
Command-line
Environment variables
System Config file
Could not read contents of 'C:\ProgramData\bat\config': The system cannot find the path specified. (os error 3).
Config file
Custom assets metadata
Could not read contents of 'C:\Users\thayes\AppData\Local\bat\metadata.yaml': The system cannot find the path specified. (os error 3).
Custom assets
'C:\Users\thayes\AppData\Local\bat' not found
Compile time information
Less version
The text was updated successfully, but these errors were encountered: