Skip to content

Don't highlight match and case as keywords in contexts where they probably aren't used as keywords#122

Closed
jpe wants to merge 2 commits intoScintillaOrg:masterfrom
jpe:python-match-case
Closed

Don't highlight match and case as keywords in contexts where they probably aren't used as keywords#122
jpe wants to merge 2 commits intoScintillaOrg:masterfrom
jpe:python-match-case

Conversation

@jpe
Copy link
Copy Markdown
Contributor

@jpe jpe commented Dec 21, 2022

Changes the python lever to classify match and case as keywords if they are in the keywords set and are in a position where they are probably keywords and not identifiers -- at the start of the line and not followed by a '=' or '.'.

There are ambiguous cases where match / case could be a keyword or identifier that are classified as a keyword. This could be resolved by scanning ahead for a terminating ':', but it would require something close to a python tokenizer and the match / case should probably be classified as keywords while the line is being entered. An example are the lines 'match (x)' and 'match (x):' -- match is an identifier in the first, but a keyword in the second.

There are cases where the statement starts on the prior line that aren't handled correctly, but should be rare and would be difficult to fix within the current approach.

I opted not to add an option to control this, but could if someone wants to highlight all match and case symbols as keywords.

Note that match and case were added to python/SciTE.properties for the tests; this doesn't seem to affect the other tests.

nyamatongwe pushed a commit that referenced this pull request Dec 26, 2022
@nyamatongwe nyamatongwe added python Caused by the Python lexer committed Issue fixed in repository but not in release labels Dec 26, 2022
@nyamatongwe
Copy link
Copy Markdown
Member

Committed with reformatting and added 'const's.

@nyamatongwe
Copy link
Copy Markdown
Member

Added 012a4bb which replaces call to isdigit with IsADigit as the character was not checked for ASCII first.

@nyamatongwe
Copy link
Copy Markdown
Member

Fixed in 5.2.2.

@nyamatongwe nyamatongwe closed this Feb 7, 2023
@nyamatongwe nyamatongwe removed the committed Issue fixed in repository but not in release label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Caused by the Python lexer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants