Skip to content

Commit

Permalink
Make JSON5 to use JSON keywords
Browse files Browse the repository at this point in the history
Fix #14205, close #14223
  • Loading branch information
mpheath authored and donho committed Oct 18, 2023
1 parent 97dd708 commit 089f7d6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,7 @@ void ScintillaEditView::setEmbeddedJSLexer()

void ScintillaEditView::setJsonLexer(bool isJson5)
{
LangType j = isJson5 ? L_JSON5 : L_JSON;
setLexerFromLangID(j);
setLexerFromLangID(isJson5 ? L_JSON5 : L_JSON);

const TCHAR *pKwArray[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };

Expand All @@ -724,15 +723,15 @@ void ScintillaEditView::setJsonLexer(bool isJson5)
keywordList2 = wstring2string(kwlW, CP_ACP);
}

execute(SCI_SETKEYWORDS, 0, reinterpret_cast<LPARAM>(getCompleteKeywordList(keywordList, j, LANG_INDEX_INSTR)));
execute(SCI_SETKEYWORDS, 1, reinterpret_cast<LPARAM>(getCompleteKeywordList(keywordList2, j, LANG_INDEX_INSTR2)));
execute(SCI_SETKEYWORDS, 0, reinterpret_cast<LPARAM>(getCompleteKeywordList(keywordList, L_JSON, LANG_INDEX_INSTR)));
execute(SCI_SETKEYWORDS, 1, reinterpret_cast<LPARAM>(getCompleteKeywordList(keywordList2, L_JSON, LANG_INDEX_INSTR2)));

execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold"), reinterpret_cast<LPARAM>("1"));
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.compact"), reinterpret_cast<LPARAM>("0"));

execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("lexer.json.escape.sequence"), reinterpret_cast<LPARAM>("1"));

if (j == L_JSON5)
if (isJson5)
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("lexer.json.allow.comments"), reinterpret_cast<LPARAM>("1"));
}

Expand Down

0 comments on commit 089f7d6

Please sign in to comment.