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

Invalid syntax highlighting with or condition `||`

Open jacek-jablonski opened this issue 2 years ago • 2 comments

Describe the bug Syntax is invalid formatted with || at the begging of the line

To Reproduce Steps to reproduce the behavior: This workflow casuses invalid hightlighting on the last line:

name: "CI / CD"

on: workflow_call

jobs:
  prepare:
    name: "Prepare"
    runs-on: "ubuntu-22.04"
    outputs:
      perform-tests: "${{ steps.should-perform-tests.outputs.perform-tests }}"
      perform-lint: "${{ steps.should-perform-lint.outputs.perform-lint }}"

    steps:
      - name: "Should perform tests"
        id: "should-perform-tests"
        run: |
          echo "perform-tests=1" >> $GITHUB_OUTPUT

      - name: "Should perform lint"
        id: "should-perform-lint"
        run: |
          echo "perform-lint=1" >> $GITHUB_OUTPUT

  ci:
    name: "CI"
    runs-on: "ubuntu-22.04"
    needs: ["prepare"]
    if: >
      needs.prepare.outputs.perform-lint == 1
      || needs.prepare.outputs.perform-tests == 1

Expected behavior The last line shouldn't be red and slanted.

Screenshots image

Extension Version v0.25.8

jacek-jablonski avatar Jun 23 '23 12:06 jacek-jablonski

This issue is still present in v0.27.2.

Would be good to add expression and if to the title as I think this bug is specific to the special-cased if key (which evaluates expressions without requiring surrouunding by ${{ }})

MRE:

name: Format website code
on:
    workflow_dispatch:
jobs:
    format:
        runs-on: ubuntu-latest
        if: >
            github.event_name == 'workflow_dispatch'
            || true
        steps:
            -  uses: actions/checkout@v4

Note how the bug extends beyond the line with || true: the following line is also wrongly highlighted (orange not blue)

Image

&& on line start is also buggy, but less so, just showing weird colors for each of the &&:

Image

corneliusroemer avatar Jul 03 '25 13:07 corneliusroemer

@corneliusroemer This issue should be fixed with #468.

Image

cdce8p avatar Jul 07 '25 11:07 cdce8p