Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad highlighting when resource dot number notation is used in template string #40

Closed
orgads opened this issue May 9, 2022 · 4 comments · Fixed by #44
Closed

Bad highlighting when resource dot number notation is used in template string #40

orgads opened this issue May 9, 2022 · 4 comments · Fixed by #44
Assignees
Labels
bug Something isn't working syntax
Milestone

Comments

@orgads
Copy link

orgads commented May 9, 2022

Server Version

0.27.0

Terraform Version

Terraform v1.1.9
on windows_amd64

Client Version

VS Code

Terraform Configuration Files

locals {
  a = ["foo"]
}
output "foo" {
  value = {
    foo = "${local.a.0}a"
    bar = "This is not highlighted as a string"
  }
}

Log Output

https://gist.github.com/orgads/9e2edc3d4ab85de5beaeba113077ae63

Expected Behavior

a after the closing brace should be highlighted as a string, and bar should be highlighted as a symbol

Actual Behavior

image

Steps to Reproduce

Open VS Code and paste the code above.

Notice that changing local.a.0 to local.a[0] solves the issue.

@radeksimko radeksimko transferred this issue from hashicorp/terraform-ls May 9, 2022
@radeksimko radeksimko transferred this issue from hashicorp/syntax May 9, 2022
@radeksimko
Copy link
Member

Hi @orgads
Thank you for the report.

Since this part of highlighting is provided by the TextMate grammars and not by the language server I moved your issue over to the extension repo.

There is a chance this may be the same problem as described in hashicorp/vscode-terraform#1040 but I haven't had the time to confirm, so leaving this open until someone has time to confirm.

@radeksimko
Copy link
Member

Turns out this is a separate issue - we just patched hashicorp/vscode-terraform#1040 upstream and I can still reproduce this:
Screenshot 2022-05-20 at 19 36 43

@radeksimko
Copy link
Member

While we work on fixing this, I'd also like to point out that more idiomatic way to write the same expression with the same meaning is with square brackets:

locals {
  a = ["foo"]
}
output "foo" {
  value = {
    foo = "${local.a[0]}a"
    bar = "This is not highlighted as a string"
  }
}

See also https://www.terraform.io/language/expressions/references#references-to-resource-attributes

@radeksimko radeksimko transferred this issue from hashicorp/vscode-terraform May 27, 2022
@radeksimko radeksimko self-assigned this Jun 6, 2022
@radeksimko
Copy link
Member

PR with a fix is now pending review in #44

@radeksimko radeksimko added this to the 0.4.0 milestone Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working syntax
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants