Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Syntax highlighting for fuzzy search previews#1634

Merged
rolandwalker merged 1 commit intomainfrom
RW/syntax-highlight-search-previews
Feb 27, 2026
Merged

Syntax highlighting for fuzzy search previews#1634
rolandwalker merged 1 commit intomainfrom
RW/syntax-highlight-search-previews

Conversation

@rolandwalker
Copy link
Contributor

Description

  • add a [search] section to myclirc with a highlight_preview option
  • leave the option off by default as it does introduce a small lag when traversing search candidates
  • optionally call pygmentize when creating the preview text
  • add pygmentize to external executables tested in --checkup
  • update TIPS

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 && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Feb 26, 2026
@github-actions
Copy link

Findings (bugs/regressions)

  1. alt-r handler references a non-existent attribute
    • In mycli/key_bindings.py the alt-r binding passes highlight_style=mycli.style. There is no MyCli.style attribute; the rest of the code uses mycli.syntax_style. This will raise AttributeError when alt-r is used (and highlight_preview is enabled or not — the attribute access happens unconditionally).
    • Fix: use mycli.syntax_style here for consistency with the ctrl-r path.
    • File: mycli/key_bindings.py

Missing tests / edge cases

  1. No tests covering highlight preview option plumbing
    • Add a unit test around search_history() options generation to ensure:
      • When highlight_preview=True and pygmentize is available, the preview command includes pygmentize with the configured syntax_style.
      • When highlight_preview=False or pygmentize missing, it uses the plain printf preview.
    • Also add a simple test around key binding handlers to ensure they pass syntax_style (and don’t reference style).

If you want, I can patch the mycli.style bug and add a minimal test.

@rolandwalker rolandwalker force-pushed the RW/syntax-highlight-search-previews branch from 7c75a89 to 70ebf1d Compare February 26, 2026 11:09
Copy link
Contributor

@scottnemes scottnemes left a comment

Choose a reason for hiding this comment

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

Can you give an example of what this does? I played around with search but couldn't see any difference, so might be looking in the wrong place

@rolandwalker
Copy link
Contributor Author

Example:

last image

Copy link
Contributor

@scottnemes scottnemes left a comment

Choose a reason for hiding this comment

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

Thanks for the example; verified the new option works as expected.

 * add a [search] section to myclirc with a highlight_preview option
 * leave the option off by default as it does introduce a small lag
   when traversing search candidates
 * optionally call pygmentize when creating the preview text
 * add pygmentize to external executables tested in --checkup
 * update TIPS
@rolandwalker rolandwalker force-pushed the RW/syntax-highlight-search-previews branch from 70ebf1d to fa5b9a1 Compare February 27, 2026 10:50
@rolandwalker rolandwalker merged commit 499cc0d into main Feb 27, 2026
8 checks passed
@rolandwalker rolandwalker deleted the RW/syntax-highlight-search-previews branch February 27, 2026 10:54
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.

2 participants