WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@tanishiking
Copy link
Contributor

before
Screenshot 2025-02-21 at 12 12 47

after
Screenshot 2025-02-21 at 12 13 48

fix #35

This commit separates the syntax highlighting rules for result types with angle brackets (result<...>) and result types without type parameters.

Previously, both types were handled in a single rule, meta.result.ty.wit, which ended at a newline (technically "after"), comma, or closing bracket. However, if a result type appeared as a parameter, the scope wouldn't end until one of these conditions was met. (As observed, the scope didn’t end even when a newline was encountered, likely because it was captured by other rules, though...).

This change simplifies the meta.result.ty.wit scope by splitting the handling of result<...> and result. Now, result<...> is handled similarly to list<...> and tuple<...>, while result without <...> is handled by result-base, which marks the result keyword as entity.name.type.result.wit.

As a consequence of this change, line comments on result<xxx> // comment will no longer be ignored. However, this is a known issue for other types as well.

Comment on lines 219 to 229
# ^^ source.wit meta.interface-item.wit meta.type-item.wit
# ^ source.wit meta.interface-item.wit meta.type-item.wit meta.whitespace.wit
# ^^ source.wit meta.interface-item.wit meta.type-item.wit entity.name.type.id.wit
# ^ source.wit meta.interface-item.wit meta.type-item.wit meta.whitespace.wit
# ^ source.wit meta.interface-item.wit meta.type-item.wit
# ^^ source.wit meta.interface-item.wit meta.type-item.wit entity.name.type.id.wit
# ^ source.wit meta.interface-item.wit meta.type-item.wit
# ^ source.wit meta.interface-item.wit meta.type-item.wit meta.whitespace.wit
# ^^^^ source.wit meta.interface-item.wit meta.type-item.wit entity.name.type.id.wit
Copy link
Contributor Author

@tanishiking tanishiking Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be source.wit meta.interface-item.wit meta.type-item.wit meta.result.ty.wit comment.line.double-slash.wit.
However, this issue applies to other types as well, and the result type worked fine only because it was treated as a special case. We should address this with a more general approach in a separate PR.

type x = i32 // hello <- this line comments will be colored with 0.3.1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's a fix #39
I would rebase once either of this or #39 is merged

@tanishiking tanishiking force-pushed the fix-35 branch 2 times, most recently from 9e7b49d to 256f285 Compare February 21, 2025 04:18
@tanishiking
Copy link
Contributor Author

Seems like this also fixes #33 ?

@tanishiking tanishiking changed the title [fix]: Separate rules for result keyword with and without <> fix: Separate rules for result keyword with and without <> Feb 21, 2025
fix bytecodealliance#35

This commit separates the syntax highlighting rules for `result` types with angle brackets (`result<...>`) and `result` types without type parameters.

Previously, both types were handled in a single rule, `meta.result.ty.wit`, which ended at a newline (technically "after"), comma, or closing bracket.
However, if a `result` type appeared as a parameter, the scope wouldn't end until one of these conditions was met.
(As observed, the scope didn’t end even when a newline was encountered, likely because it was captured by other rules, though...).

This change simplifies the `meta.result.ty.wit` scope by splitting the handling of `result<...>` and `result`.
Now, `result<...>` is handled similarly to `list<...>` and `tuple<...>`, while `result` without `<...>` is handled by `result-base`, which marks the `result` keyword as `entity.name.type.result.wit`.

As a consequence of this change, line comments on `result<xxx> // comment` will no longer be ignored. However, this is a known issue for other types as well.
@GordonSmith GordonSmith merged commit cf87929 into bytecodealliance:main May 9, 2025
2 checks passed
@tanishiking tanishiking deleted the fix-35 branch May 9, 2025 09:15
@tanishiking
Copy link
Contributor Author

Thanks! @GordonSmith

@tanishiking tanishiking mentioned this pull request May 16, 2025
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

Successfully merging this pull request may close these issues.

Syntax highlighting issue after result without <> in params

2 participants