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

Document is Open - Ignoring Event #1703

Open
1 task
gadgetmerc opened this issue Feb 29, 2024 · 3 comments
Open
1 task

Document is Open - Ignoring Event #1703

gadgetmerc opened this issue Feb 29, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@gadgetmerc
Copy link

Extension Version

v2.30.2024022914

VS Code Version

Version: 1.87.0 (Universal)
Commit: 019f4d1419fbc8219a181fab7892ebccf7ee29a2
Date: 2024-02-27T23:42:56.944Z (1 day 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.3.0

Operating System

14.3.1 (23D60)

Terraform Version

Terraform v1.5.4 on darwin_amd64

Steps to Reproduce

  1. update a terraform file
  2. save it.

Expected Behavior

The expected behavior is that the file will be formatted. I reference one file in this example but its across any TF projects I have.

Actual Behavior

No formatting is done. Looking at the output of "hashicorp terraform" i see messages like the one below. I have verified that i don't have the files open in another vscode project/window or even open in vi. lsof doesn't show it opened by anything. Not sure why its skipping the file. Running terraform fmt from the command line formats the file as expected by the vs-code plugin.

I have tried disabling all other plugins and restarting my laptop. Running out of things to try.

2024/02/29 11:30:43 rpc_logger.go:32: Incoming notification for "workspace/didChangeWatchedFiles": {"changes":[{"uri":"file:///Users/user.name/git/terraform-pmr/terraform-vp-user-profile/aurora.tf","type":2}]}
2024/02/29 11:30:43 did_change_watched_files.go:159: document is open - ignoring event for "file:///Users/user.name/git/terraform-pmr/terraform-vp-user-profile/aurora.tf"

Terraform Configuration

It doesn't matter which resources or modules are being referenced.

VSCode Settings.json
    "terraform": {
        "editor.defaultFormatter": "hashicorp.terraform",
        "editor.formatOnSave": true,
        "editor.formatOnSaveMode": "file",
        "codelens.referenceCount": true,
        "experimentalFeatures.validateOnSave": true,
    },
    "terraform-vars": {
        "editor.defaultFormatter": "hashicorp.terraform",
        "editor.formatOnSave": true,
        "editor.formatOnSaveMode": "file"
    },

Project Structure

| - variables.tf
| - aurora.tf

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
@gadgetmerc gadgetmerc added the bug Something isn't working label Feb 29, 2024
@dbanck
Copy link
Member

dbanck commented Mar 1, 2024

Hi @gadgetmerc, thanks for the report and your initial investigation.

Can you please share the full log? Saving the file should trigger a "textDocument/formatting" message and some more log output that might shed some light on the issue.

@gadgetmerc
Copy link
Author

gadgetmerc commented Mar 4, 2024

Sorry for the delay. The file saved was variables.tf and I added whitespace that it should format for me.

2024/03/04 09:21:28 opts.go:215: Received request batch of size 1 (qlen=0)
2024/03/04 09:21:28 opts.go:215: Dequeued request batch of length 1 (qlen=0)
2024/03/04 09:21:28 rpc_logger.go:32: Incoming notification for "textDocument/didSave": {"textDocument":{"uri":"file:///Users/user.name/git/terraform-pmr/terraform-vpcore-cidrs/variables.tf"}}
2024/03/04 09:21:28 opts.go:215: Received request batch of size 1 (qlen=0)
2024/03/04 09:21:28 opts.go:215: Dequeued request batch of length 1 (qlen=0)
2024/03/04 09:21:28 rpc_logger.go:32: Incoming notification for "workspace/didChangeWatchedFiles": {"changes":[{"uri":"file:///Users/user.name/git/terraform-pmr/terraform-vpcore-cidrs/variables.tf","type":2}]}
2024/03/04 09:21:28 did_change_watched_files.go:159: document is open - ignoring event for "file:///Users/user.name/git/terraform-pmr/terraform-vpcore-cidrs/variables.tf"
2024/03/04 09:21:32 opts.go:215: Received request batch of size 1 (qlen=0)
2024/03/04 09:21:32 opts.go:215: Received request batch of size 1 (qlen=1)
2024/03/04 09:21:32 opts.go:215: Dequeued request batch of length 1 (qlen=1)
2024/03/04 09:21:32 opts.go:215: Dequeued request batch of length 1 (qlen=0)
2024/03/04 09:21:32 rpc_logger.go:32: Incoming request for "textDocument/codeLens" (ID 2397): {"textDocument":{"uri":"file:///Users/user.name/git/terraform-pmr/terraform-vpcore-cidrs/cidrs.tf"}}
2024/03/04 09:21:32 rpc_logger.go:32: Incoming request for "textDocument/codeLens" (ID 2398): {"textDocument":{"uri":"file:///Users/user.name/git/terraform-pmr/terraform-vpcore-cidrs/variables.tf"}}
2024/03/04 09:21:32 rpc_logger.go:53: Response to "textDocument/codeLens" (ID 2397): []
2024/03/04 09:21:32 opts.go:215: Completed 1 requests [2.157959ms elapsed]
2024/03/04 09:21:32 rpc_logger.go:53: Response to "textDocument/codeLens" (ID 2398): []
2024/03/04 09:21:32 opts.go:215: Completed 1 requests [2.529792ms elapsed]

@dbanck
Copy link
Member

dbanck commented Mar 7, 2024

It's hard to tell without the full log, but it looks like your editor is not sending a formatting request.

Are the settings in your original post copied directly from your settings.json? To reference a language ID, you need to use [] brackets. Can you check if your settings have an entry for formatting Terraform files, like this

  "[terraform]": {
    "editor.defaultFormatter": "hashicorp.terraform",
    "editor.formatOnSave": true,
    "editor.formatOnSaveMode": "file"
  },
  "[terraform-vars]": {
    "editor.defaultFormatter": "hashicorp.terraform",
    "editor.formatOnSave": true,
    "editor.formatOnSaveMode": "file"
  },

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

No branches or pull requests

2 participants