question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Syntax highlighting is not working reliably

See original GitHub issue

Versions

This bug is reproducible in:

  • the latest version of the extension (below)
  • the latest version of the language server (below)

Extension

v2.19.0

Language Server

terraform-ls 0.25.2

VS Code

Version: 1.64.2
Commit: f80445acd5a3dadef24aa209168452a3d97cc326
Date: 2022-02-09T22:00:58.347Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0

Operating System

macOS Big Sur 11.6.2 (20G314)

Terraform Version

$ terraform version
Terraform v1.1.5
on darwin_amd64

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a main.tf with the content of the screenshots, the syntax highlight does not work.
  2. The default language will be “Terraform”
  3. Hit Ctrl+Shift+P and “Change Language Mode -> terraform-vars”
  4. The syntax highlight works

This is weird and feels not intended.

Include any relevant Terraform configuration or project structure:

resource "azurerm_resource_group" "main" {
  name     = local.resource_group_name
  location = var.location

  tags = local.all_tags
}

Please, see screenshots attached.

Weirdly working terraform-vars: terraform1

Not working Terraform: terraform2

Expected Behavior

Syntax highlighting should just work. Why are there two languages anyway?

Actual Behavior

Syntax highlighting does not work. 😦

Additional context

Extension bisect/only enabling Hashicorp Terraform extension did not fix the problem.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
dbanckcommented, Mar 21, 2022

FYI, I’ve created two issues tracking the described problems:

1reaction
Rabattkartecommented, Mar 21, 2022

Oh well, with your explanation I just realized that I had completely wrong (other?) assumptions about what the extension provides. I thought the keyword var. will be highlighted to aid with visual reviews. But now I understood that e.g. var.existing_var will be displayed inline (without any highlighting) since this is a known reference. This becomes even clearer when I hover over that variable.


I really learned a lot about debugging vscode extensions as well as how they work internally. I guess there is nothing to “fix” in this issue. I see exactly the same improvement that you mentioned:

Highlighting should be more consistent and intuitive. So we will create separate issues for each enhancement.

I’m closing this issue now since it is none. Feel free to re-open it if needed.

Thanks again! 🥇

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio Code syntax highlighting is not working for ...
Previously, I had experienced this issue with CSS after installing POSTCss extension. I looked if this only happens with a specific language.
Read more >
Broken syntax highlighting for shell scripts - Issues - GitLab
The immediate fix would be to fix the mapping between the two languages, that is [rouge]: shell -> [highlight.js]: sh . Additionally, we...
Read more >
Javascript syntax highlighting it not working
After I enabled the extension, syntax highlighting started working again. Go to Tools > Extensions and Updates > Installed. And look for "Visual...
Read more >
improved syntax highlighting in VSCode extension ...
Semantic highlighting is not instant - VSCode will actively ask our language server to provide a set of semantic tokens for an entire...
Read more >
Kotlin syntax highlighting not working | Bitbucket Cloud - Jira
Kotlin syntax highlighting not working. Gathering Impact: Assignee: Priority: Resolution: Gathering Impact. Unassigned. Medium. Unresolved. Component/s.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found