Skip to content

Commit

Permalink
ensure leading whitespace to shell scripts is scoped as shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall committed Nov 19, 2023
1 parent 98fbe16 commit 00c4f67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion YamlPipeline.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ contexts:
pop: 1

embedded-bash:
- clear_scopes: 1
#- clear_scopes: 1
- meta_include_prototype: false

script-block-scalar-begin:
- meta_include_prototype: false
- include: comment
- match: ^([ ]+)(?! ) # match first non-empty line to determine indentation level
scope: source.shell.bash.embedded
# note that we do not check if indentation is enough
embed: embedded-bash
escape: ^(?!\1|\s*$)
Expand Down
4 changes: 4 additions & 0 deletions tests/syntax_test_azure_devops3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ jobs:
displayName: 'Create work item on failure'
- pwsh: echo $(Build.BuildNumber) //output updated build number
# TODO: use powershell syntax above instead of Bash
- bash: |
echo 'testing123'
# <- source.yaml.pipeline.azure-devops source.shell.bash.embedded
# ^^^^ source.shell.bash meta.function-call.identifier support.function.echo
7 changes: 5 additions & 2 deletions tests/syntax_test_github_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ jobs:
# ^ string.quoted.double.yaml punctuation.definition.string.end.yaml - meta.interpolation
run: |
if [[ "${{ matrix.sublime-build }}" == "latest" ]]; then
# <- source.yaml.pipeline.github-actions source.shell.bash
# ^^ support.function.test.begin
# ^ punctuation.definition.string.begin
# ^^^ punctuation.section.interpolation.begin
Expand All @@ -155,9 +156,11 @@ jobs:
- name: Run syntax tests
# ^ punctuation.definition.block.sequence.item - source.shell
run: |
cd st_syntax_tests
./syntax_tests
cd st_syntax_tests && ./syntax_tests
# <- source.yaml.pipeline.github-actions source.shell.bash.embedded
# ^^ source.shell.bash meta.function-call.identifier support.function.cd
env:
# ^^^ meta.mapping.key meta.string string.unquoted.plain.out
# TODO: scope env var names as variables
myNull: ${{ null }}
# ^^^^ constant.language.null
Expand Down

0 comments on commit 00c4f67

Please sign in to comment.