Skip to content

Conversation

@shinaoka
Copy link
Contributor

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: AAAAAABBBBBBCCCCCCC, searching for "CCCCCCC" might show "BBBBBB" as a previous message, which is misleading.

Changes

  • Filter out m.replace events from events_before and events_after in local search results
  • Add unit tests for the filtering logic

Files Changed

  • src/Searching.ts - Add filter for edit events in context
  • test/unit-tests/Searching-test.ts - Add tests

Tests

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 from events_before and events_after, while regular messages are preserved
  • preserves non-edit events in context - Verifies that non-edit events remain in context unchanged

Technical Details

Edit events are identified by checking content["m.relates_to"].rel_type === "m.replace".

Checklist

Edit events (m.replace) in search result context (events_before/events_after)
would show as confusing "previous messages" when they're actually just
edit history of the same message.

This fix filters out m.replace events from the context to provide
a cleaner search result display.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant