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

C#: Added context check for from keyword #2970

Merged
merged 1 commit into from
Jul 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/prism-csharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
typeDeclaration: 'class enum interface struct',
// contextual keywords
// ("var" and "dynamic" are missing because they are used like types)
contextual: 'add alias and ascending async await by descending from get global group into join let nameof not notnull on or orderby partial remove select set unmanaged value when where',
contextual: 'add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into join let nameof not notnull on or orderby partial remove select set unmanaged value when where',
// all other keywords
other: 'abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield'
};
Expand Down
2 changes: 1 addition & 1 deletion components/prism-csharp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions tests/languages/csharp/issue2968.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
func(from: "America", to: "Asia"); // Prism incorrectly highlights "from" as a keyword

from element in list; // no issues here

----------------------------------------------------

[
["function", "func"],
["punctuation", "("],
["named-parameter", "from"],
["punctuation", ":"],
["string", "\"America\""],
["punctuation", ","],
["named-parameter", "to"],
["punctuation", ":"],
["string", "\"Asia\""],
["punctuation", ")"],
["punctuation", ";"],
["comment", "// Prism incorrectly highlights \"from\" as a keyword"],

["keyword", "from"],
" element ",
["keyword", "in"],
" list",
["punctuation", ";"],
["comment", "// no issues here"]
]
4 changes: 2 additions & 2 deletions tests/languages/csharp/keyword_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fixed
float
for
foreach
from
from foo;
get
global
goto
Expand Down Expand Up @@ -146,7 +146,7 @@ yield
["keyword", "float"],
["keyword", "for"],
["keyword", "foreach"],
["keyword", "from"],
["keyword", "from"], " foo", ["punctuation", ";"],
["keyword", "get"],
["keyword", "global"],
["keyword", "goto"],
Expand Down