alphapapa / ement.el

A Matrix client for GNU Emacs
GNU General Public License v3.0
476 stars 44 forks source link

Event insertion sequence bug in ement-notify--log-to-buffer ? #191

Closed phil-s closed 10 months ago

phil-s commented 11 months ago

I just spotted a log entry being inserted somewhere other than the end of the log buffer (and not chronologically), so I'm looking at ement-notify--log-to-buffer and trying to see whether it seems buggy in that regard.

The call to ement-room--insert-event seems to have full control over this, and I presume is intended to insert the event in its chronological position in the room, but I'm guessing that the multi-room nature of the log buffer is causing it some confusion.

I saw messages 3 and 4 inserted in the following non-chronological order:

13:54  RoomA » user1> Message 1
15:12  RoomC » user3> Message 3
14:02  RoomB » user2> Message 2
15:12  RoomC » user3> Message 4

I'm not convinced that point was at the end of the buffer when Message 3 came in, so it might well have been at the position the message was inserted.

alphapapa commented 11 months ago

Haven't looked at the code yet, but this sounds like an issue with ewoc that I had to workaround in ement-room by ensuring that the buffer's window is selected before inserting the node. It might be a bug in EWOC, but I haven't dug that deep into it. Anyway, the fix might be that simple. (It was annoying to debug, because it only happened if the buffer had a visible window and the window was not selected.)

alphapapa commented 10 months ago

@phil-s I think that should fix it. Please let me know if you encounter the problem again.