Add settings search highlighting - #8646
Conversation
There was a problem hiding this comment.
Pull request overview
Adds normalized settings-search indexing and a non-mutating highlight overlay for settings pages, so matches can be visually emphasized across common Swing components (including HTML text and table renderers) while preserving navigation behavior and section expansion state.
Changes:
- Introduces
SettingsSearchTextutilities for extracting rendered display text (plain/HTML/table/header) and mapping normalized tokens back to source offsets. - Adds
SettingsSearchHighlightLayerUIand wires it intoSettingsContentHostto paint highlight overlays without modifying underlying component text/layout. - Updates settings routing/pane logic to index rendered route/page text, exclude internal route IDs, preserve expansion state during filtering, and adds extensive unit/UI tests.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| megamek/src/megamek/client/ui/settings/SettingsSearchText.java | New rendered-text extraction + normalization/range mapping utilities for search/highlighting. |
| megamek/src/megamek/client/ui/settings/SettingsSearchHighlightLayerUI.java | New LayerUI overlay that computes and paints match highlight bounds across supported Swing components. |
| megamek/src/megamek/client/ui/settings/SettingsRoute.java | Switches route search indexing to rendered path text and rendered section text (excluding internal IDs). |
| megamek/src/megamek/client/ui/settings/SettingsPane.java | Tracks current route + expansion state across filtering; applies highlights and restores expansion state on clear. |
| megamek/src/megamek/client/ui/settings/SettingsPagePanel.java | Expands search indexing to include rendered titles/summaries/static content and full-page text; exposes expansion state APIs. |
| megamek/src/megamek/client/ui/settings/SettingsNavigationPanel.java | Publishes normalized filter changes via listener callback. |
| megamek/src/megamek/client/ui/settings/SettingsContentHost.java | Wraps content scrollpane in JLayer and enables simple scroll mode to support overlay repainting. |
| megamek/unittests/megamek/client/ui/settings/SettingsSearchTextTest.java | New tests for rendered text extraction, normalization, tokenization, and range mapping. |
| megamek/unittests/megamek/client/ui/settings/SettingsSearchHighlightLayerUITest.java | New headless UI tests verifying overlay painting behavior and geometry across component types. |
| megamek/unittests/megamek/client/ui/settings/SettingsRouteTest.java | Adds coverage ensuring internal IDs aren’t searchable and HTML labels don’t leak tokens. |
| megamek/unittests/megamek/client/ui/settings/SettingsPaneTest.java | Adds coverage for filter-driven expansion behavior, restoration, highlighting, and stale index clearing. |
| megamek/unittests/megamek/client/ui/settings/SettingsPagePanelTest.java | Adds coverage for page/body search text, rendered HTML, static components, and table/header search text behavior. |
| megamek/unittests/megamek/client/ui/settings/SettingsNavigationPanelTest.java | Adds coverage that filter callbacks publish normalized text. |
| megamek/unittests/megamek/client/ui/settings/SettingsContentHostTest.java | Adds coverage for highlight non-mutation and viewport SIMPLE_SCROLL_MODE. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8646 +/- ##
============================================
+ Coverage 32.58% 32.77% +0.19%
- Complexity 23857 24221 +364
============================================
Files 3428 3441 +13
Lines 333573 334799 +1226
Branches 58537 58797 +260
============================================
+ Hits 108694 109747 +1053
- Misses 212381 212435 +54
- Partials 12498 12617 +119 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
IllianiBird
left a comment
There was a problem hiding this comment.
Nothing serious stands out
Summary
JLayeroverlay that supports plain text, Swing HTML, read-only editor panes, table cells, and standard table headersAcknowledgements
This work builds on @hokvel's experimental MekHQ PR MegaMek/mekhq#9566, which introduced the user-visible-text-only search direction and highlighted matches in Campaign Options. This PR generalizes those ideas into the shared settings framework and replaces HTML text mutation with a non-mutating
JLayeroverlay after testing showed that HTML insertion could alter layout.Validation
./gradlew :megamek:test --tests "megamek.client.ui.settings.*" :megamek:checkstyleMain :megamek:checkstyleTestVideo
Recording.2026-08-05.135348.mp4