Skip to content

Fix highlighting for set-prefixed identifiers#1913

Open
puneetdixit200 wants to merge 3 commits into
dbcli:mainfrom
puneetdixit200:fix-set-prefix-highlighting
Open

Fix highlighting for set-prefixed identifiers#1913
puneetdixit200 wants to merge 3 commits into
dbcli:mainfrom
puneetdixit200:fix-set-prefix-highlighting

Conversation

@puneetdixit200
Copy link
Copy Markdown
Contributor

Description

Fixes #1872.

MyCliLexer now recognizes identifiers that start with set before falling through to Pygments' MySQL lexer, so table names such as settings_123 stay highlighted as a single name instead of splitting set as a keyword. The standalone SET keyword still falls through to the inherited lexer.

I added a regression test, updated the changelog, and added my name to the authors list.

Tests run:

  • PYTHONPATH=. UV_CACHE_DIR=/tmp/mycli-1872-uv-cache uv run --extra dev pytest test/pytests/test_lexer.py -q (failed before the lexer fix, passed after)
  • PYTHONPATH=. UV_CACHE_DIR=/tmp/mycli-1872-uv-cache uv run --extra dev pytest test/pytests/test_lexer.py test/pytests/test_naive_completion.py test/pytests/test_clistyle.py -q
  • PYTHONPATH=. UV_CACHE_DIR=/tmp/mycli-1872-uv-cache uv run --extra dev ruff check
  • PYTHONPATH=. UV_CACHE_DIR=/tmp/mycli-1872-uv-cache uv run --extra dev ruff format --check
  • PYTHONPATH=. UV_CACHE_DIR=/tmp/mycli-1872-uv-cache uv run --extra dev mypy mycli/lexer.py test/pytests/test_lexer.py
  • git diff --check

I used AI assistance while preparing this change and reviewed/tested the result locally.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format

Comment thread mycli/lexer.py
tokens = {
"root": [(r"\brepair\b", Keyword), (r"\boffset\b", Keyword), inherit],
"root": [
(r"\bset[\w$]+\b", Name),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this was fixed upstream, can we add a TODO comment on the set line explaining that it won't be needed after Pygments is upgraded above v2.20.0 ?

Comment thread changelog.md Outdated
* Add CI on macOS.
* Add limited CI on Windows.
* Add limited CI on Windows WSL.
* Keep identifiers that start with `set` highlighted as names.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it should be in a Bug Fixes section rather than Internal, since it is visible to the user.

@puneetdixit200 puneetdixit200 force-pushed the fix-set-prefix-highlighting branch from d8a1aff to 840a36a Compare June 4, 2026 15:20
@rolandwalker
Copy link
Copy Markdown
Contributor

Thanks for the updates! There seem to be some unrelated changes added.

@puneetdixit200 puneetdixit200 force-pushed the fix-set-prefix-highlighting branch from 190b9ac to c9cb6f8 Compare June 4, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When the table name starts with "set" (e.g. "settings"), the "set" prefix is highlighted as if it was a reserved keyword.

3 participants