Skip to content

fix (checks): Handle overlapping non-nested higlights#19507

Merged
nijel merged 9 commits into
WeblateOrg:mainfrom
gersona:18932_overlapping_highlights
May 13, 2026
Merged

fix (checks): Handle overlapping non-nested higlights#19507
nijel merged 9 commits into
WeblateOrg:mainfrom
gersona:18932_overlapping_highlights

Conversation

@gersona
Copy link
Copy Markdown
Contributor

@gersona gersona commented May 12, 2026

I wasn't able to find real world examples yet, but the logic should cover those
I've started a conversation here hoping to get some feedback from the community

Comment thread weblate/checks/tests/test_placeholders.py Outdated
@gersona gersona force-pushed the 18932_overlapping_highlights branch from 6b1cd47 to 36cde11 Compare May 12, 2026 09:10
@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented May 12, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 9 changed May 13, 2026, 7:09 AM

@gersona gersona marked this pull request as ready for review May 12, 2026 12:36
@nijel nijel requested a review from Copilot May 12, 2026 13:42
@nijel nijel added this to the 2026.5 milestone May 12, 2026
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

Fixes highlighting span handling to correctly deal with partially overlapping (non-nested) highlight ranges, avoiding broken highlight rendering/replacement behavior when multiple checks/flags match intersecting spans.

Changes:

  • Added merge_highlight_spans() utility and switched highlight_string() to merge overlaps into union spans.
  • Updated placeholder check highlighting to collect matches per-flag/pattern and merge overlaps.
  • Adjusted replace_highlighted() to advance last_end across overlaps, and added regression tests + changelog entry.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
weblate/checks/utils.py Introduces span-union merging and uses it for highlight_string(); tweaks overlap handling in replace_highlighted().
weblate/checks/placeholders.py Updates placeholder highlighting to merge overlaps across multiple placeholder patterns/flags.
weblate/checks/tests/test_utils.py Adds a regression test for partially overlapping (non-nested) highlights.
weblate/checks/tests/test_placeholders.py Adds a regression test covering overlapping placeholder patterns.
docs/changes.rst Documents the changed placeholder highlighting behavior for the 2026.5 changelog.

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

Comment thread weblate/checks/utils.py
Comment thread weblate/checks/placeholders.py
Comment thread weblate/checks/tests/test_utils.py Outdated
Comment thread weblate/checks/tests/test_placeholders.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@nijel nijel enabled auto-merge (squash) May 12, 2026 15:03
@nijel nijel self-assigned this May 12, 2026
auto-merge was automatically disabled May 13, 2026 06:16

Head branch was pushed to by a user without write access

@nijel nijel merged commit bfbd466 into WeblateOrg:main May 13, 2026
30 of 33 checks passed
@nijel
Copy link
Copy Markdown
Member

nijel commented May 13, 2026

Merged, thanks for your contribution!

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.

Overlapping highlighting

3 participants