Skip to content

Commit 158f25d

Browse files
C#: Added context check for from keyword (#2970)
1 parent 0fd01ea commit 158f25d

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

components/prism-csharp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
typeDeclaration: 'class enum interface struct',
4848
// contextual keywords
4949
// ("var" and "dynamic" are missing because they are used like types)
50-
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',
50+
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',
5151
// all other keywords
5252
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'
5353
};

components/prism-csharp.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/csharp/issue2968.test

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
func(from: "America", to: "Asia"); // Prism incorrectly highlights "from" as a keyword
2+
3+
from element in list; // no issues here
4+
5+
----------------------------------------------------
6+
7+
[
8+
["function", "func"],
9+
["punctuation", "("],
10+
["named-parameter", "from"],
11+
["punctuation", ":"],
12+
["string", "\"America\""],
13+
["punctuation", ","],
14+
["named-parameter", "to"],
15+
["punctuation", ":"],
16+
["string", "\"Asia\""],
17+
["punctuation", ")"],
18+
["punctuation", ";"],
19+
["comment", "// Prism incorrectly highlights \"from\" as a keyword"],
20+
21+
["keyword", "from"],
22+
" element ",
23+
["keyword", "in"],
24+
" list",
25+
["punctuation", ";"],
26+
["comment", "// no issues here"]
27+
]

tests/languages/csharp/keyword_feature.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fixed
3535
float
3636
for
3737
foreach
38-
from
38+
from foo;
3939
get
4040
global
4141
goto
@@ -146,7 +146,7 @@ yield
146146
["keyword", "float"],
147147
["keyword", "for"],
148148
["keyword", "foreach"],
149-
["keyword", "from"],
149+
["keyword", "from"], " foo", ["punctuation", ";"],
150150
["keyword", "get"],
151151
["keyword", "global"],
152152
["keyword", "goto"],

0 commit comments

Comments
 (0)