hashicorp / vscode-terraform

HashiCorp Terraform VSCode extension
https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform
Mozilla Public License 2.0
922 stars 179 forks source link

Syntax highlighting broken with `SELECT` statements #1792

Closed vthaker-alti closed 2 months ago

vthaker-alti commented 2 months ago

Extension Version

v2.31.0

VS Code Version

Version: 1.91.0 Commit: ea1445cc7016315d0f5728f8e8b12a45dc0a7286 Date: 2024-07-01T18:52:41.959Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Linux x64 6.5.0-41-generic

Operating System

Linux 9cc62ba41e90 6.5.0-41-generic #41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun 3 11:32:55 UTC 2 x86_64 GNU/Linux

Terraform Version

Terraform v1.7.5 on linux_amd64

Steps to Reproduce

  1. Write a string with the word SELECT followed by a space
  2. The syntax breaks as the LS no longer recognises it as a normal string.
  3. Any brackets and comments following the string will not use proper highlighting anymore.

image

Note: It doesn't matter if you have any word after SELECT and space.

image

Expected Behavior

The LS should treat it as a normal string

Actual Behavior

The LS does not treat it as a normal string and breaks syntax highlighting after it

Terraform Configuration

locals {
  query_statement_1 = "SELECT"
  # something
}

locals {
  query_statement_2 = "SELECT "
  # something
}

Project Structure

.
├── 0-providers.tf
└── 1-split-cost-data-export.tf

Gist

No response

Anything Else?

No response

Workarounds

Although not ideal, as a workaround we can use a temp local variable for the word SELECT to preserve the highlighting

image

References

No response

Help Wanted

Community Note

dbanck commented 2 months ago

Hi @vthaker-alti,

Interesting discovery! At a first glance I can't reproduce the problem: CleanShot 2024-07-12 at 14 10 28@2x

Our TextMate grammar, which is the source for the syntax highlighting, also doesn't handle the SELECT keyword in a special way either.

Do you have other SQL highlighting extensions installed? Can you share the your full list of active extensions (use code --list-extensionsto get it)?

vthaker-alti commented 2 months ago

@dbanck Thank you for your response. You are correct, I installed an extension iuyoy.highlight-string-code ages ago that was causing the issue.

image

After disabling it the issue went away. I uninstalled the extension now. Thanks for the tip.

Closing the issue as it was a user error.

github-actions[bot] commented 1 month ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.