Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,23 @@ fn ansi_theme() -> Theme {
// (scopes, palette slot, italic)
let rules: &[(&str, Color, bool)] = &[
("comment, punctuation.definition.comment", ansi(8), true),
(
"meta.structure.dictionary.key, meta.structure.dictionary.key string, meta.structure.dictionary.key punctuation.definition.string, meta.mapping.key, meta.mapping.key string, meta.mapping.key punctuation.definition.string, support.type.property-name",
ansi(4),
false,
),
("string, punctuation.definition.string", ansi(2), false),
("constant.character.escape", ansi(6), false),
(
"constant.numeric, constant.language, constant.character",
ansi(3),
false,
),
(
"constant.other.color, punctuation.definition.constant.css",
ansi(5),
false,
),
(
"keyword, storage.modifier, storage.type.function",
ansi(5),
Expand All @@ -82,14 +92,28 @@ fn ansi_theme() -> Theme {
false,
),
(
"entity.name.function, support.function, meta.function-call",
"entity.name.function, support.function, variable.function, support.macro, entity.name.function.macro, entity.name.macro, punctuation.definition.macro",
ansi(4),
false,
),
("variable.parameter", ansi(6), false),
("entity.name.tag", ansi(4), false),
("entity.other.attribute-name", ansi(3), false),
("support.constant.property-value", ansi(3), false),
("variable.language, support.constant", ansi(1), false),
("markup.heading", ansi(4), false),
("meta.diff.header.from-file", ansi(1), false),
("meta.diff.header.to-file", ansi(2), false),
(
"punctuation.definition.from-file, punctuation.definition.to-file, punctuation.definition.inserted, punctuation.definition.deleted",
ansi(5),
false,
),
(
"meta.diff.range, punctuation.definition.range.diff",
ansi(6),
false,
),
("markup.inserted", ansi(2), false),
("markup.deleted", ansi(1), false),
("invalid", ansi(1), false),
Expand Down
17 changes: 17 additions & 0 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@ fn terminal_theme_emits_only_palette_colours() {
);
}

#[test]
fn terminal_theme_bash_highlighting_distinguishes_arguments_and_flags() {
ink()
.args([
"--plain", "--color", "always", "--theme", "terminal", "--width", "80",
])
.write_stdin("```bash\ngit commit -m \"feat\"\n```\n")
.assert()
.success()
.stdout(
predicate::str::contains("\x1b[34mgit")
.and(predicate::str::contains("\x1b[39m commit"))
.and(predicate::str::contains("\x1b[36m -"))
.and(predicate::str::contains("\x1b[32mfeat")),
);
}

#[test]
fn doctor_reports_without_a_tty() {
// In a test harness stdout is a pipe: the protocol query must be skipped
Expand Down