matrix-org / matrix-appservice-irc

Node.js IRC bridge for Matrix
Apache License 2.0
462 stars 151 forks source link

Message diffing does not handle replacing a repeated word correctly #1574

Open progval opened 2 years ago

progval commented 2 years ago

Describe the bug When a word is present twice in a message and the second occurrence is replaced, the resulting sed-like diff does not make it clear the second occurrence is replaced

To Reproduce Steps to reproduce the behavior:

  1. Send foo bar baz bar quux
  2. Edit to replace the second bar occurence, so the message looks like: foo bar baz qux quux
  3. IRC users see this:
17:39:36 <+val[m]> foo bar baz bar quux
17:39:43 <+val[m]> s/bar/qux/

which is ambiguous as to which occurrence is being replaced (and it would be incorrect when run through an actual sed).

Expected behavior Include more context (surrounding words) so it is unambiguous.