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

Completions for variables include the var. (unless you don't type the dot) #1746

Open
1 task
robbruce opened this issue Apr 23, 2024 · 3 comments
Open
1 task
Labels
bug Something isn't working upstream/hcl

Comments

@robbruce
Copy link

Extension Version

v2.30.1

VS Code Version

Version: 1.87.2 (Universal)
Commit: 863d2581ecda6849923a2118d93a088b0745d9d6
Date: 2024-03-08T15:21:31.043Z (1 mo ago)
Electron: 27.3.2
ElectronBuildId: 26836302
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.1.0

Operating System

macOS Sonoma Version 14.1.1

Terraform Version

Terraform v1.8.1 on darwin_arm64

Steps to Reproduce

  1. Copy terraform code
  2. Type my_v the after var., wait for auto complete
  3. Press enter

Expected Behavior

Within a for loop, when you type var.my_var, it completes to var.var.my_var

Actual Behavior

Within a for loop, when you type var.my_var, it should complete to var.my_var

Terraform Configuration

variable "my_var" {
  type = map(string)
}

locals {
  test = { for key, value in var.}
}

Project Structure

No response

Gist

No response

Anything Else?

No response

Workarounds

No response

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@robbruce robbruce added the bug Something isn't working label Apr 23, 2024
@robbruce
Copy link
Author

Continuation of #1624, but that issue was closed

@robbruce
Copy link
Author

terraform-bug

@dbanck
Copy link
Member

dbanck commented Apr 26, 2024

Thanks for the report @robbruce! I'm able to reproduce the bug.

I want to treat this as a separate issue from #1624, because we're in the context of a for expression. Depending on the type of expression (e.g. list, tuple, for, ...) the HCL parser behaves differently when it encounters incomplete configuration. Sometimes we can recover enough information to provide meaningful and correct completions, and sometimes the parser is thrown off by the impartial expression and we end up with a bug like this.

A fix for this will require upstream changes to the HCL parser. hashicorp/hcl-lang#370 has some more context on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream/hcl
Projects
None yet
Development

No branches or pull requests

2 participants