Skip to content

Syntax highlighting gets confused if return type ends with a number #207

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

Closed
aeschli opened this issue Jul 14, 2016 · 3 comments
Closed

Syntax highlighting gets confused if return type ends with a number #207

aeschli opened this issue Jul 14, 2016 · 3 comments

Comments

@aeschli
Copy link

aeschli commented Jul 14, 2016

From @kayahr on July 4, 2016 11:9

  • VSCode Version: 1.2.1
  • OS Version: Debian GNU/Linux 8.5

Steps to Reproduce:

  1. Open new TypeScript file.
  2. Copy/Paste the following code:
class Vector2 {
    public foobar(): Vector2 {
        return this;
    }
}

class Vector2D {
    public foobar(): Vector2D {
        return this;
    }
}

The method in the class Vector2D is properly colored but in the class Vector2 the syntax highlighting gets confused. Looks like this has something to do with the class name ending with a number.

Here is a screenshot showing a wrong color of the return and thiskeywords:

highlighting

In larger source code this gets quite confusing because subsequent methods in the same class are also affected.

Copied from original issue: microsoft/vscode#8720

@kayahr
Copy link

kayahr commented Jul 28, 2016

By the way: The same problem can be reproduced right here on Github when formatting source code with language=typescript:

class Vector2 {
    public foobar(): Vector2 {
        return this;
    }
}

class Vector2D {
    public foobar(): Vector2D {
        return this;
    }
}

And a small workaround for the issue is placing the return type in parantheses:

class Vector2 {
    public foobar(): (Vector2) {
        return this;
    }
}

Or using Allman style instead of 1TBS:

class Vector2
{
    public foobar(): Vector2
    {
        return this;
    }
}

@glen-84
Copy link

glen-84 commented Aug 7, 2016

Duplicate of #188 and #153.

@sheetalkamat
Copy link
Member

Fixed by #257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants