Azure / Azure/bicep

Typing commit character ":" when a resource completion is selected while typing out a ternary expression will output "resource:" instead of just ":"

Open
#10,179 0 comments 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
v0.15.31

**Describe the bug**
Completion item commit character `:` was assigned to resource symbols in the completion list to assist with the nested resource accessor syntax (ex. `resourceA::childResource`). This conflicts with typing out ternary expressions. https://github.com/Azure/bicep/pull/10043 will bring resource symbols to the top of the completion list for `resource.dependsOn` array item completions. This will cause a resource symbol to be preselected. When typing out a ternary expression's `:` while in that type of array, it will result in `condition ? aResource aResource:` instead of `condition ? aResource :` assuming `aResource` is the first completion that shows up.

**To Reproduce**
Steps to reproduce the behavior:

Bicep:

1. Use this bicep code in VS Code:
```
resource aResource 'Microsoft.Storage/storageAccounts@2022-09-01' = {
name: 'bar'
}
var test = false
resource foo 'Microsoft.Storage/storageAccounts@2022-09-01' = {
name: 'foo'
dependsOn: [
test ? aResource
]
}
```
2. Type `:` after "aResource " on line 8 when a resource symbol is preselected in the completion list.

Expected:
3. `:` only gets typed up after typing `:`

Actual:
3. `aResource:` gets typed out after typing `:` assuming `aResource` is the preselected completion item while typing.

**Additional context**
![322-bicep-colon-commit](https://user-images.githubusercontent.com/5498623/226933049-bb9adfb1-319a-44c4-9daa-f97e1914699c.gif)

Contributor guide

Open the contributing guide

Research direction

Reproduce the Bicep example in VS Code, focusing on resource-symbol completion and the `:` commit character while typing the ternary expression in the `dependsOn` array. Trace the completion behavior for the preselected resource item; done means typing `:` produces only the ternary colon, while nested resource accessor syntax remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.