microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164k stars 29.2k forks source link

Syntax Highlighting for Multi-line template strings is broken #36065

Closed MelvIsntNormal closed 7 years ago

MelvIsntNormal commented 7 years ago
Extension Author (truncated) Version
fish Ted 0.0.4
haskelly UCL 0.4.26
better-toml bun 0.3.1
npm-intellisense chr 1.3.0
githistory don 0.2.3
python don 0.7.0
gitlens eam 5.6.0
tslint eg2 1.0.10
vscode-livescript-preview ehe 1.0.2
prettier-vscode esb 0.24.0
language-haskell jus 2.4.0
vscode-rust kal 0.4.2
fish-ide lun 0.3.0
cpptools ms- 0.13.1
livescript pse 0.1.1
java red 0.11.0
elm sbr 0.15.1
vim vsc 0.10.1

Steps to Reproduce:

  1. Paste the following code into a file with Typescript syntax highlighting:
    
    interface DBConnection {
    query<Input, Output>(query: string)
    execute(query: any, input: any)
    }

interface Stats {}

export function getStats(database: DBConnection, id: number) { const query = database.query<[number], Stats>( SELECT * FROM statistics WHERE unit_id = $1 )

return database.execute(query, [id])

}

export function getSessionStats(database: DBConnection, id: number, session :number) { const query = database.query<[number, number], Stats>( SELECT * FROM statistics WHERE unit_id = $1 AND session = $2 )

return database.execute(query, [id, session])

}



The template strings will not be highlighted properly, and it throws off the highlighting for the rest of the file. Interestingly, the bug only occurs when there is more than one type parameter: remove `Stats` and it formats correctly.

<!-- Launch with `code --disable-extensions` to check. -->
Reproduces without extensions: Yes
mjbvz commented 7 years ago

Thanks. Opened https://github.com/Microsoft/TypeScript-TmLanguage/issues/530 to track this upstream