-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
bat::PrettyPrinter::syntaxes()
iterate over new bat::Syntax
…
…struct We can't keep `syntect::parsing::SyntaxReference` as part of the public API, because that might prevent us from bumping to syntect 6.0.0 without also bumping bat to v2.0.0, once we reach v1.0.0. So introduce a new stripped down struct `Syntax` and return that instead. Let it be fully owned to make the API simple. It is not going to be in a hot code path anyway. I have looked at all code of our 27 dependents but I can't find a single instance of this method being used, so this change should be safe for v1.0.0.
- Loading branch information
Showing
4 changed files
with
35 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use bat::PrettyPrinter; | ||
|
||
#[test] | ||
fn syntaxes() { | ||
let printer = PrettyPrinter::new(); | ||
let syntaxes: Vec<String> = printer.syntaxes().map(|s| s.name).collect(); | ||
|
||
// Just do some sanity checking | ||
assert!(syntaxes.contains(&"Rust".to_string())); | ||
assert!(syntaxes.contains(&"Java".to_string())); | ||
assert!(!syntaxes.contains(&"this-language-does-not-exist".to_string())); | ||
|
||
// This language exists but is hidden, so we should not see it; it shall | ||
// have been filtered out before getting to us | ||
assert!(!syntaxes.contains(&"Git Common".to_string())); | ||
} |