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

Syntax highlighting for match and case #1215

Closed
cdce8p opened this issue Apr 30, 2021 · 9 comments
Closed

Syntax highlighting for match and case #1215

cdce8p opened this issue Apr 30, 2021 · 9 comments
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version waiting for upstream Waiting for upstream to release a fix

Comments

@cdce8p
Copy link

cdce8p commented Apr 30, 2021

It would be nice if syntax highlighting for match and case could be added.

Screen Shot 2021-04-30 at 17 04 04

def http_error(status: int):
    match status:
        case 400:
            return "Bad request"
        case 404:
            return "Not found"
        case 418:
            return "I'm a teapot"
@jakebailey
Copy link
Member

Thanks for the report; at the moment we rely on the TextMate profile built into VS Code to display these kinds of keywords. I'm surprised they haven't been added there, but I do think we should be emitting keywords as tokens in the semantic highlighter as well.

@cdce8p
Copy link
Author

cdce8p commented May 1, 2021

After searching a bit more, I found these two existing issues:
microsoft/vscode#120734
MagicStack/MagicPython#235

I've also opened a PR MagicStack/MagicPython#237 to recognize match and case as keywords, at least in a match statement.

@bschnurr bschnurr added the waiting for upstream Waiting for upstream to release a fix label May 3, 2021
@github-actions github-actions bot removed the triage label May 3, 2021
@jakebailey jakebailey added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label May 5, 2021
@jakebailey
Copy link
Member

In the meantime while we wait for VS Code and such to pull in those changes, I've modified our semantic tokenizer to output match and case as keyword tokens:

matchcase

@cdce8p
Copy link
Author

cdce8p commented May 5, 2021

@jakebailey That's great! Thanks 🚀

@jakebailey
Copy link
Member

This issue has been fixed in version 2021.5.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202150-5-may-2021

@Jaakkonen
Copy link

For people using pyright extension for development of it I think there's no other workaround than using a MagicPython extension built from the PR branch (rebased or not).

@scarf005
Copy link

scarf005 commented Aug 20, 2022

default themes and github themes support match case syntax, however majority of other themes does not support them out of the box.

running Inspect editor tokens and scopes shows result like this:
_01

_02

could there be any way to overwrite custom themes to support match case?
(using editor.tokenColorCustomizations for every single themes would too much work)

@debonte
Copy link
Contributor

debonte commented Aug 21, 2022

@scarf005, this issue has been closed for a long time. Please open a new issue for your suggestion.

@scarf005
Copy link

@scarf005, this issue has been closed for a long time. Please open a new issue for your suggestion.

alright, referenced in new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version waiting for upstream Waiting for upstream to release a fix
Projects
None yet
Development

No branches or pull requests

6 participants