Skip to content

Single-pass highlight formatting (DSK-135)#176

Merged
daisuke8000 merged 1 commit into
mainfrom
fix/dsk-135-highlight-single-pass
Jul 5, 2026
Merged

Single-pass highlight formatting (DSK-135)#176
daisuke8000 merged 1 commit into
mainfrom
fix/dsk-135-highlight-single-pass

Conversation

@daisuke8000

@daisuke8000 daisuke8000 commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Run highlight regex in a single find_iter pass; return None when nothing matches so the formatted line buffer is left unchanged.
  • Build ANSI spans with write! and assign the result directly to the output buffer when highlighting applies.

Test plan

  • cargo test -p rustern-core --lib render::highlight

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes
    • ハイライト表示が、条件に一致した行だけに適用されるようになりました。
    • 一致しない行では不要な装飾を行わず、表示の一貫性が向上しました。

Avoid clearing and rebuilding the line buffer when the highlight regex
does not match; assign highlighted output directly when it does.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5e26822e-1bea-4911-a941-bddf25729843

📥 Commits

Reviewing files that changed from the base of the PR and between 2234a48 and 099a23b.

📒 Files selected for processing (1)
  • crates/rustern-core/src/render/highlight.rs

📝 Walkthrough

Walkthrough

SternHighlightLineFormatter のハイライト処理を変更しました。highlight_default_line は Option を返すようになり、正規表現にマッチしない場合は None を返して余計な文字列生成を回避します。format_into 側は Some の場合のみバッファを更新します。実装では出力文字列の遅延確保と write! マクロによるスタイル付与を採用。マッチあり・マッチなしの両ケースをカバーするテストが更新・追加されています。

Sequence Diagram(s)

上記の隠しレビュースタック内の図を参照してください。

Possibly related issues

  • DSK-135: highlight.rs の format_into/マッチ処理をマッチなし時の余計な処理を避けるよう変更し、write! でANSIスパンを構築する点が本PRと一致。

Poem

うさぎがコードを覗き込む
マッチなしなら手を止めて
Someのときだけ色を塗る
write!でぴょんと飛び跳ねて
テストも二つ、仲間入り 🐰
🚥 Pre-merge checks | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning Conventional Commitsのprefixがなく、要件のfeat:/fix:等を満たしていません。 feat: などのprefixを付け、72文字以内で変更内容を具体的に表すタイトルにしてください。
Description check ⚠️ Warning 必須の『概要』『変更理由』セクションがなく、テンプレート構成に沿っていません。 『## 概要』『## 変更理由』を追加し、各項目をテンプレートどおり埋めてください。

Comment @coderabbitai help to get the list of available commands.

@daisuke8000
daisuke8000 merged commit 0353a36 into main Jul 5, 2026
3 checks passed
@daisuke8000
daisuke8000 deleted the fix/dsk-135-highlight-single-pass branch July 5, 2026 14:53
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.

1 participant