on master help sign in
Fix syntax detection for files called 'rails'

closes #1008

commitc4031ad65c72650938039dce9be5dcc0672a3d8a authorsharkdp <davidpeter@web.de> dateSun 24 May 2020, 10:22 (6 years ago) parent2eaced4
2 files changed+16
src/assets.rs+11 src/syntax_mapping.rs+5
src/assets.rs+11
@@ -481,4 +481,15 @@ mod tests {
481481 "Bourne Again Shell (bash)"
482482 );
483483 }
484+
485+ #[test]
486+ fn issue_1008() {
487+ let test = SyntaxDetectionTest::new();
488+
489+ assert_eq!(
490+ test.syntax_for_file_with_content("bin/rails", "#!/usr/bin/env ruby"),
491+ "Ruby"
492+ );
493+ assert_eq!(test.syntax_for_file("example.rails"), "HTML (Rails)");
494+ }
484495}
src/syntax_mapping.rs+5
@@ -42,6 +42,11 @@ impl<'a> SyntaxMapping<'a> {
4242 )
4343 .unwrap();
4444
45+ // See #1008
46+ mapping
47+ .insert("rails", MappingTarget::MapToUnknown)
48+ .unwrap();
49+
4550 mapping
4651 }
4752