Skip to content

feat(code-diff): scope search to removed | added | changed lines#4061

Draft
john-traas wants to merge 12 commits intomainfrom
diff-viewer
Draft

feat(code-diff): scope search to removed | added | changed lines#4061
john-traas wants to merge 12 commits intomainfrom
diff-viewer

Conversation

@john-traas
Copy link
Copy Markdown
Contributor

Summary

Extends the in-diff search of limel-code-diff from "removed lines only" to a user-selectable scope: removed (default), added, or changed. The picker is an inline icon-only <limel-button-group> placed before the search input.

  • Default scope on open: removed if there are deletions, otherwise added (auto-fallback).
  • Scope resets on close; no new public prop, no cross-session persistence.
  • Search-toggle visibility now appears for any change (was: deletions only).

Implementation

  • New pure helpers in search-utils.ts: pickDefaultScope and lineMatchesScope (full unit-test coverage).
  • code-diff.tsx gains a searchScope @State() field; renderContent consults lineMatchesScope; the toggle visibility predicate is widened.
  • <limel-button-group> rendered as the first child of the search bar; emits change to onScopeChange which narrows the id without an unchecked cast.
  • Translations updated across all 8 locales (en, da, de, fi, fr, nl, no, sv) — old code-diff.search value generalized, plus four new keys for the scope-picker labels.

Test plan

  • Open the dev server and verify on a normal diff: search opens with "Removed" pre-selected; switching to "Added" / "Changed" updates highlights and the match counter.
  • Verify the compare_arrows icon resolves visibly. (Fallbacks: swap_vert, sync_alt.)
  • Verify minus / plus_math render sensibly for "Removed" / "Added".
  • Verify on an additions-only diff that the search toggle appears and opens with "Added" pre-selected.
  • Verify on identical inputs that the search toggle is hidden.
  • Verify Esc closes the panel and reopening returns to the smart default.

Notes

  • 87 unit tests pass across the four code-diff specs; lint and prettier are clean.
  • No new public @Prop / @Event; component remains @beta.
  • The CSS classes search-bar__scope and search-bar__input are decorative — styling is by tag selector. Pre-existing for __input, mirrored for __scope. Could be cleaned up in a follow-up if full BEM discipline is wanted.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-4061/

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bef6b0ce-dd8b-4eee-8884-9e575f06612a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch diff-viewer

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends limel-code-diff’s in-diff search from being limited to removed lines to a user-selectable scope (removed, added, or changed), with a compact scope picker embedded in the search bar. It also adjusts default behavior and visibility so search is available whenever there is any diff.

Changes:

  • Added SearchScope plus pure helpers pickDefaultScope and lineMatchesScope (with unit tests) to support scoped searching.
  • Updated limel-code-diff to track searchScope, render a <limel-button-group> scope picker, and apply highlighting/counting only to lines within the active scope.
  • Updated all locales to generalize the search label and add new scope-related translation keys.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/components/code-diff/code-diff.tsx Adds scoped search state, scope picker UI, and applies scope filtering during render/highlighting.
src/components/code-diff/search-utils.ts Introduces SearchScope and pure helpers for default-scope selection and scope matching.
src/components/code-diff/search-utils.spec.ts Adds unit coverage for the new scope helper functions.
src/components/code-diff/code-diff.scss Ensures the new scope picker doesn’t shrink in the search bar layout.
src/translations/en.ts Updates search label and adds new search-scope translation keys.
src/translations/da.ts Updates search label and adds new search-scope translation keys.
src/translations/de.ts Updates search label and adds new search-scope translation keys.
src/translations/fi.ts Updates search label and adds new search-scope translation keys.
src/translations/fr.ts Updates search label and adds new search-scope translation keys.
src/translations/nl.ts Updates search label and adds new search-scope translation keys.
src/translations/no.ts Updates search label and adds new search-scope translation keys.
src/translations/sv.ts Updates search label and adds new search-scope translation keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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