Skip to content

Commit c891681

Browse files
committed
[Python] Highlight type() as builtin function.
1 parent 861a2fb commit c891681

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scintilla/lexers/LexPython.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ Sci_Position CheckBraceFormatSpecifier(const StyleContext &sc, LexAccessor &styl
374374
}
375375

376376
constexpr bool IsMatchExpressionStart(int ch, int chNext) noexcept {
377-
return IsADigit(ch) || (ch == '.' && IsADigit(chNext))
377+
return IsNumberStart(ch, chNext)
378378
|| (chNext != '=' && AnyOf(ch, '*', '+', '-', '~', '(', '[', '{'));
379379
}
380380

@@ -480,6 +480,7 @@ void ColourisePyDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyl
480480
if (!IsIdentifierCharEx(sc.ch)) {
481481
char s[MaxKeywordSize];
482482
sc.GetCurrent(s, sizeof(s));
483+
bool builtin = false;
483484
if (keywordLists[KeywordIndex_Keyword].InList(s)) {
484485
sc.ChangeState(SCE_PY_WORD);
485486
if (StrEqual(s, "def")) {
@@ -488,6 +489,7 @@ void ColourisePyDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyl
488489
kwType = KeywordType::Class;
489490
} else if (StrEqualsAny(s, "match", "case", "type")) {
490491
if (visibleChars != sc.LengthCurrent() || !IsSoftKeyword(s, sc, styler)) {
492+
builtin = s[0] == 't';
491493
sc.ChangeState(SCE_PY_IDENTIFIER);
492494
}
493495
}
@@ -508,7 +510,7 @@ void ColourisePyDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyl
508510
if (kwType != KeywordType::None) {
509511
sc.ChangeState(static_cast<int>(kwType));
510512
} else if (sc.GetLineNextChar() == '(') {
511-
sc.ChangeState(SCE_PY_FUNCTION);
513+
sc.ChangeState(builtin ? SCE_PY_BUILTIN_FUNCTION : SCE_PY_FUNCTION);
512514
}
513515
}
514516
if (sc.state != SCE_PY_WORD) {

0 commit comments

Comments
 (0)