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

Partial loss of Syntax highlighting when updating to Visual Studio 2017 RC #14422

Closed
JohnWeisz opened this issue Mar 2, 2017 · 16 comments
Closed
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@JohnWeisz
Copy link

JohnWeisz commented Mar 2, 2017

TypeScript Version: 2.1.5

Code

import * as React from "react";
export var t = new Date();

Expected behavior:

Keywords import, as, from, export, var and new should be highlighted (by default, blue).

Actual behavior:

Only var is highlighted, as shown on this screenshot:

2017-03-02

Additional notes

  • TypeScript build succeeds
  • All project types are affected
  • VS 2017 RC was installed next to a VS 2015 installation
  • Both VS 2015 and 2017 are Community edition
  • The new installation of VS 2017 did not affect the earlier VS 2015 one
  • JSX/TSX syntax highlighting is gone too
@JohnWeisz
Copy link
Author

JohnWeisz commented Mar 2, 2017

Something is clearly wrong:

wat

I believe the word IContentLoader should be of the same color as WebContentLoader. Strangely, the export keyword is highlighted here.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 2, 2017

is this only for a single project? are all files showing the same behavior? if so where is the second screenshot from? what happens if you open a new .ts file in a new session of VS?

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Mar 2, 2017
@JohnWeisz
Copy link
Author

JohnWeisz commented Mar 2, 2017

Multiple projects, thousands of files, all display the exact same behavior. I restarted VS multiple times (also, as I said, in VS2015 the syntax highlighting works flawlessly), and, among other things, tried:

  • Running VS 2017 RC as admin
  • Disabling/enabling TextMate extension (disabling it completely eliminated all syntax highlighting, except for class names)
  • Installing TS 2.2 (although it had no effect regarding the displayed version in the About window of VS)
  • Running devenv /setup

This is how it looks in a larger scope:

wat

As you can see, it's "mostly" intact, but it seems as if the keyword recognition was leaking between tokens. Also, I believe that's not how methods are supposed to look.

@JohnWeisz
Copy link
Author

JohnWeisz commented Mar 2, 2017

Interestingly enough, the same happens with plain .js files (which I believe are now using the Typescript language service for autocompletion as well). For example, the new keyword is not colored.

@JohnWeisz
Copy link
Author

JohnWeisz commented Mar 2, 2017

Alright. Visual Studio 2017 RC is recognizing new, import, export, from, as keywords as Operator, and changing the color of operators in the Fonts & Colors settings will once again highlight these, while also highlighting regular operators and brackets around function parameters (?).

I believe something's not quite right in the TS language service. This is how it looks when applying a custom styling to Operator (picked a strong red one for it to be clearly visible):

wat

The readonly keyword is still not highlighted.

Note: everything else is default, this is a fresh installation.

@Tragetaschen
Copy link

I have the very same problem.

I started with VS2015 Professional this morning (TS 2.2) and installed VS2017 Professional RTM (TS 2.1) and the syntax highlighting is broken in exactly the same way as @JohnWeisz describes.

@Tragetaschen
Copy link

For example, I clone https://github.com/tragetaschen/angular-issue-n14513 and choose from the context menu of the src folder to "Open in Visual Studio". I then open main.ts and get this:

image

@louis-gale
Copy link

Looks like someone fundamentally broke the Typescript IClassifier! Below is an example where the public keyword changes its colouring depending on on the code:

before

Notice how the second public keyword is not coloured blue. If i remove the contents of the first array, then the second public keyword becomes correctly coloured:

after

This would also explain why the keywords are being incorrectly classified as Operators in the example that @JohnWeisz posted.

@billti
Copy link
Member

billti commented Mar 10, 2017

Hmmmm.... trying the snippet from @Xcalllibur and the repro from @Tragetaschen , I don't see any problems. Screen clippings below. I even messed around with the default theme to see if this might have an impact, but all looked good.

That said, there's definitely something up here. This has been reported in #14523 also. Can you take a look at the questions I just posted there and see if anything here might apply to your environments?

Thanks, and sorry for the inconvenience.

syntax1

syntax2

@jramsay
Copy link
Member

jramsay commented Mar 11, 2017

@Xcalllibur, @JohnWeisz : Thanks for helping us with this issue! TypeScript & JavaScript now use TextMate language files to inform classification. Some additional things to try that might help isolate the problem here:

  1. Can you confirm that other TSLS features are working correctly on your installation? (formatting, completions, etc).

  2. There is a known issue with TextMate support in VS where sometimes there are missing colors. To make sure this isn’t the case here can you try running the following from a VS Developer cmd prompt to see if it resolves the issue:
    • devenv.exe /updateconfiguration
    • devenv.exe /setup

  3. What is your VS installation directory?
    Ex: C:\Program Files[ (x86)]\Microsoft Visual Studio 15.0\Common7\IDE

  4. Does the tmLanguage folder exist under the TypeScript installation path?
    Ex: C:\Program Files\Microsoft Visual Studio 15.0\Common\IDE\CommonExtensions\Microsoft\TypeScript\tmLanguage

  5. Do you have any custom grammar files (.tmLanguage, .tmTheme) located in your user profile?
    Ex: %userprofile%.vs\Extensions

  6. Can you verify this isn’t a TM language caching issue:

  • Close VS
  • Go to the TexMateCache location:
  • %localappdata%\Microsoft\VisualStudio[15.0XXXXX]\TextMateCache
  • Delete all the .cache files in this directory
  • Reopen VS and try to repro
    Does this resolve the issue?
  1. Do you have the TypeScript TextMate registry key set correctly?
    ◦Close VS
    ◦Open regedit
    ◦Select HKLM
    ◦File > Load Hive …
    ◦Open %localappdata%\Microsoft\VisualStudio\15.0_xxx\privateregistry.bin (you can name the hive VS)
    ◦Now navigate to:
    Computer\HKEY_LOCAL_MACHINE\VS\Software\Microsoft\VisualStudio\15[XXXXX]_Config\TextMate\Repositories

Does the TypeScript reg key exist? The directory should match the tmLanguage folder path from question 2 – is it the same?

Note: you'll need to unload the hive (File > Unload Hive) before you can open VS again.

@louis-gale
Copy link

@billti @jramsay I can confirm that the fix provided by Peter-Juhasz in the thread you linked solved my issue, namely:

Overwrite files in "%userprofile%.vs\Extensions\typescript\syntaxes" with the ones from Visual Studio's "CommonExtensions\Microsoft\TypeScript\tmLanguage".

I then had to close all my files and reopen them to get the syntax highlighting to work (that is after restarting Visual Studio). Interestingly, before updating these files I tried deleting what was in my %userprofile% typescript folder and the syntax highlighting was still broken.

I think it is relevant to mention that i also had Visual Studio 2015 installed on this machine with the latest Web Essentials extension installed.

@jramsay I ran through your questions (1- 7) before trying this fix and none of them helped unfortunately. I don't have time to post detailed answers but i can confirm there was nothing out of the ordinary with my registry settings, etc.

@Tragetaschen
Copy link

@jramsay

  1. Yes, formatting, completions, etc. work correctly
  2. No, after running those two commands (the second one needs elevation), the issue still persists
  3. C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE
  4. Yes, this folder exists (Common7, though)
  5. (see 6)
  6. Yes, there's a whole list. I tried uninstalling @madskristensen Syntax Highlighting Pack extension, but the entire folder remained available (uninstall issue?). When I manually removed its typescript folder, syntax highlighting was entirely gone. I then deleted %localappdata%'s TextMateCache folder and syntax highlighting went back to normal.
  7. Didn't do that

@Tragetaschen
Copy link

Tragetaschen commented Mar 13, 2017

I just repeated the entire process:

  • Install Syntax Highlighting Pack
  • Note that syntax highlighting of TypeScript files is broken
  • Remove the Syntax Highlighting Pack
    • Uninstall the extension
    • Clear the user's %userprofile%/.vs/Extensions folder
    • Remove the %localappdata%/Microsoft/VisualStudio/15.0_[...]/TextMateCache folder
  • Note that syntax highlighting of TypeScript files works

@madskristensen
Copy link

madskristensen commented Mar 13, 2017

I just released version 2.6 of the Syntax Highlighting Pack with a fix. The fix was to remove both the JavaScript and the TypeScript Textmate bundles.

@Tragetaschen
Copy link

I can confirm that. Thanks @madskristensen!

@RyanCavanaugh RyanCavanaugh added External Relates to another program, environment, or user action which we cannot control. and removed Needs More Info The issue still hasn't been fully clarified labels Mar 13, 2017
@nuander
Copy link

nuander commented Nov 14, 2017

I had to remove the syntax highlighting pack 2.7 in order to get code coloring back in my ts files

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

9 participants