mirror of
https://github.com/lotabout/skim.git
synced 2026-09-10 07:16:23 -04:00
* Add --hide-nth flag to hide fields while keeping them searchable Introduce a `--hide-nth <fieldspec>` option that takes the same comma-separated field index expressions as `--nth`/`--with-nth`. The listed fields are removed from the displayed line but remain part of the text used for matching, so a query can still match them. Characters in the hidden fields are ignored for match highlighting and horizontal scrolling. Implementation: - Resolve the fieldspec to byte ranges in the same coordinate space as the matching/display text and store them as `hidden_ranges` in DefaultSkimItem metadata, exposed via a new `SkimItem::hidden_ranges()` trait method. text()/output() keep the full text so hidden fields stay searchable and are preserved on output. - DefaultSkimItem::display() removes hidden characters and remaps match highlight positions into visible coordinates (project_visible_text / project_match_indices); this path takes precedence over ANSI styling. - ItemRenderer::render_item applies the same projection to derive the visible sub-line text and hscroll match range, so hidden characters are ignored for horizontal scrolling. Add unit tests for range normalization/projection and item behavior, plus insta snapshot tests covering display removal, searchability, and hscroll. Update ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCunXeAFMYAFduTc8SNjSM * Preserve ANSI colors for surviving text under --hide-nth Previously the hidden-field rendering path was applied ahead of the ANSI display branch and rebuilt the line from the ANSI-stripped text, so combining --hide-nth with --ansi dropped the colors of the visible fields. Integrate hidden-field removal into the ANSI branch instead: after parsing the styled spans, drop the hidden characters while preserving each span's style (retain_visible_spans) and remap the match positions into the resulting visible coordinate space, then run the normal highlighting. The plain (non-ANSI) branch keeps its project-and-to_line handling. Surviving characters now keep their ANSI colors while hidden fields stay searchable. Add unit tests for ANSI color preservation and remapped highlighting, plus ANSI color-snapshot integration tests. Update ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCunXeAFMYAFduTc8SNjSM * Set hidden fields via builder instead of DefaultSkimItem::new param Remove the `hidden_fields` parameter from `DefaultSkimItem::new` and set the hidden fields through a `hidden_fields(&[FieldRange], &Regex)` builder method instead. The builder resolves the fields against the item's own `text()` (the same coordinate space `new` would have used), so the result is identical while keeping `new`'s signature unchanged for its many existing call sites. The reader chains `.hidden_fields(&opt.hidden_fields, &opt.delimiter)` onto construction. Revert the extra `&[]` argument at the other call sites (selector, fuzz target, tests) and update the hide-nth tests to use the builder. Update ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCunXeAFMYAFduTc8SNjSM * chore: generate files --------- Co-authored-by: Claude <noreply@anthropic.com>
30 lines
2.1 KiB
Plaintext
30 lines
2.1 KiB
Plaintext
---
|
|
source: tests/ansi.rs
|
|
description: "input: bytes b\"\\x1b[32mgreen\\x1b[0m \\x1b[31mred\\x1b[0m plain\\n\"\noptions: --ansi --delimiter --hide-nth 2\nafter:\n @type \"red\""
|
|
---
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
" "
|
|
"> green plain "
|
|
" 1/1 0/0"
|
|
"> red "
|
|
cursor: (24, 6)
|