microsoft / vscode-mssql

Visual Studio Code SQL Server extension.
Other
1.53k stars 454 forks source link

Syntax highlighting - incorrect highlighting for table name when schema not used in front #1575

Open willstocks opened 4 years ago

willstocks commented 4 years ago

Steps to Reproduce:

  1. Add the following SQL:
    SELECT
    table1.ID AS ID1,
    table.ID AS ID,
    table3.ID AS ID2,
    FROM
    dbo.table1 WITH(NOLOCK)
    INNER JOIN dbo.table WITH(NOLOCK) ON table1.t1id = table.id
    INNER JOIN dbo.table2 WITH(NOLOCK) ON table1.t2id = table2.id
  2. See the following output (line three is highlighted incorrectly and glaringly differently to all other tables as standard?) image

However the highlighting appears to partially work if you specify the schema in front of table.id: image but you lose the highlighting on actual column name?

This gets even messier when you start using aliases

willstocks commented 4 years ago

Things get even weirder to look at as soon as you throw cursive/italics in to the mix...

On the most part, it seems most of my queries are 99% italic???

micek-petr commented 3 years ago

Hi willstocks, 1) there is a typo in your code - you left a colon before the FROM keyword after "ID2," 2) you are using a special keyword "table" as a real table name which is not allowed in MSSQL.

willstocks commented 3 years ago

Hi @micek-petr

Good catch! Quick pseudo-code is not always best.

However, regardless of changing these over (see below), the inconsistent formatting remains (excuse the color scheme and font changes!):

image

All of my tables have the same schema, so defining dbo in-front of all queries has always been unnecessary (in my case, appreciate this isn't necessarily generic!) and it makes working with SQL in VSCode rather unkind on the brain and the eyes! 🤣

micek-petr commented 3 years ago

Hi @willstocks

This is what it looks like on v1.10.1: image

Would you please try to upgrade from v1.8.0 to v1.10.1 and check it again?