Skip to content

Highlight Rust async and await as keywords - #3892

Open
JMak-Security wants to merge 1 commit into
sharkdp:masterfrom
JMak-Security:gh-1534-async-await-highlight
Open

Highlight Rust async and await as keywords#3892
JMak-Security wants to merge 1 commit into
sharkdp:masterfrom
JMak-Security:gh-1534-async-await-highlight

Conversation

@JMak-Security

Copy link
Copy Markdown

Closes #1534. Carries forward #3849 (by @coyaSONG), open since 2026-07-18 with zero review activity.

The bug

assets/patches/Rust.sublime-syntax.patch patches bat's vendored copy of sublimehq/Packages' Rust.sublime-syntax (pinned at submodule commit 759d6eed). That vendored file's keyword.control.rust match only covers:

- match: \b(break|else|for|if|loop|match|while|continue)\b

async and await aren't in the list, so both render as plain text instead of keywords.

The fix

Add async|await to the same alternation, in the same style as the rest of the list:

- match: \b(async|await|break|else|for|if|loop|match|while|continue)\b

Verification

I don't have a way to run bat's full asset-build pipeline here (assets/create.sh needs the sublimehq/Packages submodule initialized, which is large enough that it wasn't practical to fetch in full). Instead I verified the fix concretely:

  • Fetched the exact pinned submodule commit's copy of Rust.sublime-syntax directly (not the current upstream HEAD, which has since restructured this whole section — upstream now already lists async|await|else|for|if|loop|match|try|while|yield together, so this is purely a local vendoring-lag fix, not something that needs a submodule bump).
  • Confirmed the patch's @@ -139 +139 @@ context matches that pinned file exactly, line for line.
  • Actually ran patch --strip=0 < patches/Rust.sublime-syntax.patch against it (the same invocation create.sh uses) and confirmed it applies cleanly with no fuzz, producing the expected async|await|break|... line.

Also carries forward #3849's regression test: an async fn with chained .await calls in tests/syntax-tests/source/Rust/output.rs, with the matching expected highlighted output (async/await colored the same as the other keyword.control.rust entries) in tests/syntax-tests/highlighted/Rust/output.rs.

bat's Rust syntax highlighting patch (assets/patches/Rust.sublime-syntax.patch)
targets an older snapshot of sublimehq/Packages' Rust.sublime-syntax
(pinned submodule commit 759d6eed) whose keyword.control.rust match
only lists break|else|for|if|loop|match|while|continue. async and
await aren't included, so both render as plain text instead of
keywords.

Add async|await to that same alternation, matching the style already
used for the rest of the keyword list. Verified against the actual
pinned submodule content (fetched directly rather than the current
upstream HEAD, which has since restructured this section entirely)
that the patch context at line 139 matches exactly and applies
cleanly with `patch --strip=0`.

Adds a regression test case (async fn with chained .await calls) and
its expected highlighted output, generated to match bat's existing
Monokai Extended color scheme (keyword.control.rust colored the same
as the other control-flow keywords already in that list).

Closes sharkdpgh-1534.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust's async await is not highlighted correctly

1 participant