fix: Filter out edit events from search result context #31525
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR: Filter out edit events from search result context
Summary
When searching for text that matches an edited message, the search result context (
events_before/events_after) may include previous edit events of the same message. These appear as confusing "previous messages" when they're actually just edit history.For example, if a message was edited:
AAAAAA→BBBBBB→CCCCCCC, searching for "CCCCCCC" might show "BBBBBB" as a previous message, which is misleading.Changes
m.replaceevents fromevents_beforeandevents_afterin local search resultsFiles Changed
src/Searching.ts- Add filter for edit events in contexttest/unit-tests/Searching-test.ts- Add testsTests
Unit tests added in
test/unit-tests/Searching-test.ts:filters out edit events (m.replace) from context events- Verifies that edit events are removed fromevents_beforeandevents_after, while regular messages are preservedpreserves non-edit events in context- Verifies that non-edit events remain in context unchangedTechnical Details
Edit events are identified by checking
content["m.relates_to"].rel_type === "m.replace".Checklist
public/exportedsymbols have accurate TSDoc documentation.