Skip to content

Commit

Permalink
C#: Added context check for from keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Jun 26, 2021
1 parent 42fabfe commit 3bbcbe3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
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

0 comments on commit 3bbcbe3

Please sign in to comment.