mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-11-04 09:01:56 +00:00 
			
		
		
		
	Merge pull request #3206 from sharkdp/make_map_syntax_case_insensitive
Make map-syntax target case insensitive
This commit is contained in:
		@@ -15,6 +15,7 @@
 | 
			
		||||
- Fix crash for multibyte characters in file path, see issue #3230 and PR #3245 (@HSM95)
 | 
			
		||||
- Add missing mappings for various bash/zsh files, see PR #3262 (@AdamGaskins)
 | 
			
		||||
- Send all bat errors to stderr by default, see #3336 (@JerryImMouse)
 | 
			
		||||
- Make --map-syntax target case insensitive to match --language, see #3206 (@keith-hall)
 | 
			
		||||
 | 
			
		||||
## Other
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -163,7 +163,7 @@ impl HighlightingAssets {
 | 
			
		||||
 | 
			
		||||
        if let Some(MappingTarget::MapTo(syntax_name)) = syntax_match {
 | 
			
		||||
            return self
 | 
			
		||||
                .find_syntax_by_name(syntax_name)?
 | 
			
		||||
                .find_syntax_by_token(syntax_name)?
 | 
			
		||||
                .ok_or_else(|| Error::UnknownSyntax(syntax_name.to_owned()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -259,6 +259,13 @@ impl HighlightingAssets {
 | 
			
		||||
            .map(|syntax| SyntaxReferenceInSet { syntax, syntax_set }))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn find_syntax_by_token(&self, token: &str) -> Result<Option<SyntaxReferenceInSet>> {
 | 
			
		||||
        let syntax_set = self.get_syntax_set()?;
 | 
			
		||||
        Ok(syntax_set
 | 
			
		||||
            .find_syntax_by_token(token)
 | 
			
		||||
            .map(|syntax| SyntaxReferenceInSet { syntax, syntax_set }))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn get_syntax_for_file_name(
 | 
			
		||||
        &self,
 | 
			
		||||
        file_name: &OsStr,
 | 
			
		||||
 
 | 
			
		||||
@@ -2821,6 +2821,27 @@ fn highlighting_independant_from_map_syntax_case() {
 | 
			
		||||
        .stderr("");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[test]
 | 
			
		||||
fn map_syntax_target_syntax_case_insensitive() {
 | 
			
		||||
    let expected = bat()
 | 
			
		||||
        .arg("-f")
 | 
			
		||||
        .arg("--map-syntax=*.config:json")
 | 
			
		||||
        .arg("map-syntax_case.Config")
 | 
			
		||||
        .assert()
 | 
			
		||||
        .get_output()
 | 
			
		||||
        .stdout
 | 
			
		||||
        .clone();
 | 
			
		||||
 | 
			
		||||
    bat()
 | 
			
		||||
        .arg("-f")
 | 
			
		||||
        .arg("--map-syntax=*.config:json")
 | 
			
		||||
        .arg("map-syntax_case.Config")
 | 
			
		||||
        .assert()
 | 
			
		||||
        .success()
 | 
			
		||||
        .stdout(expected)
 | 
			
		||||
        .stderr("");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[test]
 | 
			
		||||
fn strip_ansi_always_strips_ansi() {
 | 
			
		||||
    bat()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user