vscode-github-actions icon indicating copy to clipboard operation
vscode-github-actions copied to clipboard

Expression grammar improvements

Open cdce8p opened this issue 8 months ago • 0 comments

This PR bundles a few expression grammar improvements. To review it might help to look at each commit individually. If preferred, I can also split these of into separate PRs.

The examples below are mainly taken from https://github.com/home-assistant/core/blob/dev/.github/workflows/ci.yaml

Fix syntax highlighting for if blocks

Before After
Screenshot 2025-05-03 at 15 05 46 Screenshot 2025-05-03 at 15 06 14

Before the || would be interpreted as the start of an unquoted block and break the syntax highlighting until the next job starts.

Fixes #224

Disable syntax highlighting for if keys in comments

Before After
Screenshot 2025-05-03 at 15 12 08 Screenshot 2025-05-03 at 15 12 42
Screenshot 2025-05-03 at 15 14 51 Screenshot 2025-05-03 at 15 14 51

Multiline if blocks didn't change since they weren't even recognized in the first place previously

Fixes: #259 Fixes partially: #158 (not addressed here inline-expressions inside comments: https://github.com/github/vscode-github-actions/issues/158#issuecomment-1570255022)

Fix syntax highlighting for inline expressions spanning multiple lines

Before After
Screenshot 2025-05-03 at 15 18 48 Screenshot 2025-05-03 at 15 19 05

This is quite a common pattern, especially for cache key and restore-keys.

One caveat of this change is how it affects invalid expressions. E.g. missing the closing }}. IMO it isn't as bad since it clearly highlights the invalid syntax. There is also the opportunity to improve on it later.

Before After
Screenshot 2025-05-03 at 15 20 52 Screenshot 2025-05-03 at 15 21 24

Fix nested curly brackets

Before After
Screenshot 2025-05-03 at 19 14 53 Screenshot 2025-05-03 at 19 15 13

Side effect I discovered while testing. Seems these cases are also fixed now.

Fixes #394 Fixes #223

cdce8p avatar May 03 '25 17:05 cdce8p