Skip to content

Commit

Permalink
Support JSON property without double quotes.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Dec 17, 2018
1 parent 77acd8c commit ed49db6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
10 changes: 10 additions & 0 deletions scintilla/lexers/LexJSON.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ static void ColouriseJSONDoc(Sci_PositionU startPos, Sci_Position length, int in
buf[wordLen] = 0;
if (strcmp(buf, "true") == 0 || strcmp(buf, "false") == 0 || strcmp(buf, "null") == 0) {
styler.ColourTo(i - 1, SCE_C_WORD);
} else if (ch == ':' || IsASpace(ch)) {
bool isProp = ch == ':' || chNext == ':';
if (!isProp) {
Sci_PositionU pos = i + 1;
while (IsASpace(styler.SafeGetCharAt(pos++)));
isProp = styler[pos - 1] == ':';
}
if (isProp) {
styler.ColourTo(i - 1, SCE_C_LABEL);
}
}
state = SCE_C_DEFAULT;
wordLen = 0;
Expand Down
1 change: 0 additions & 1 deletion src/EditLexers/EditStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#define NP2STYLE_XMLIdentifier 63149
#define NP2STYLE_XMLSGML 63150
#define NP2STYLE_XMLCDATA 63151
#define NP2STYLE_JSONKey 63152
//63161-63300 Web
//63301-63320 CSS
#define NP2STYLE_Class 63320
Expand Down
2 changes: 1 addition & 1 deletion src/EditLexers/stlJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
static EDITSTYLE Styles_JSON[] = {
EDITSTYLE_DEFAULT,
{ SCE_C_WORD, NP2STYLE_Keyword, EDITSTYLE_HOLE(L"Keyword"), L"fore:#0000FF" },
{ SCE_C_LABEL, NP2STYLE_JSONKey, EDITSTYLE_HOLE(L"Key"), L"fore:#A46000" },
{ SCE_C_LABEL, NP2STYLE_Property, EDITSTYLE_HOLE(L"Property"), L"fore:#A46000" },
{ SCE_C_STRING, NP2STYLE_String, EDITSTYLE_HOLE(L"String"), L"fore:#008000" },
{ SCE_C_NUMBER, NP2STYLE_Number, EDITSTYLE_HOLE(L"Number"), L"fore:#FF0000" },
{ SCE_C_OPERATOR, NP2STYLE_Operator, EDITSTYLE_HOLE(L"Operator"), L"fore:#B000B0" },
Expand Down

0 comments on commit ed49db6

Please sign in to comment.