Skip to content

Find a resource name that comes before a longer one on the same line - #52

Open
xperiandri wants to merge 1 commit into
mrlacey:mainfrom
xperiandri:find-all-names-on-a-line
Open

xperiandri wants to merge 1 commit into
mrlacey:mainfrom
xperiandri:find-all-names-on-a-line

Conversation

@xperiandri

@xperiandri xperiandri commented Oct 27, 2026 •

Copy link
Copy Markdown

Summary

Fixes #61.

When a line uses more than one resource file, the text of a name is not shown if a longer name is used later on the same line. For example, in Strings.A + Resources.B only Resources.B gets its text, and in Strings.A, Resources.B, Strings.C the first Strings.A is missed.

IndexOfAnyAsync now returns the earliest occurrence of any of the names, as its name says, so every name on a line is found, from left to right. Tests for it are added, and four of them fail without the change.

Cause, changes and verification

Cause

GetAllIndexesAsync asks IndexOfAnyAsync for the next match and carries on after it. IndexOfAnyAsync returned the first occurrence of the longest name that occurs anywhere in the rest of the line, so a shorter name that stands earlier was skipped.

Changes

  • IndexOfAnyAsync returns the earliest occurrence of any of the names. A line that uses one name, or the longer names first, gives the same result as before.
  • The caller needs no change: ResourceAdornmentManager already goes through the indexes from right to left, which expects them in ascending order.
  • Tests for IndexOfAnyAsync and GetAllIndexesAsync are added to the test project, and four of them fail without the change. They also pin down what already worked: a name used twice, a name that ends with another one (MyResources. and Resources.), no match and no names.

Verification

  • The solution builds without new warnings and all 19 tests pass.
  • The change was not tried in the Visual Studio Experimental instance.

🤖 Generated with Claude Code

`GetAllIndexesAsync` took the longest of the names that occur anywhere in
the rest of a line and carried on after its first occurrence. A shorter
name that stood before a longer one on the same line was skipped, so its
text was not shown. In `Strings.A + Resources.B` only `Resources.B` was
found.

`IndexOfAnyAsync` now returns the earliest occurrence of any of the
names, which is what its name says, so every name on a line is found,
from left to right. A line that uses one name, or the longer names
first, gives the same indexes as before.

Added tests for both methods. Four of them fail without the change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

The extension shows no text for a resource name that comes before a longer name on the same line

1 participant