Paste NG

Paste NG

380k Downloads

Chat parts are pasted in the wrong order

tflo opened this issue · 13 comments

commented

If you compose a message containing more chars than fit with Blizz's limitation, PasteNG will post the second part before the first one.

Expected Behavior: The parts should be pasted in order.

IIRC, it worked fine before TWW, but not 100% sure.

commented

I just tested it with a 0.25 delay, which seems to be more stable.
I have also changed it, so it only delays for the guild chat.

I have released 11.0.2-20240905-1 with your fixes - thank you for helping improve this 😀

commented

One could also move the delay increase to after the C_Timer (or start with local delay = -0.25), so the first line would be faster (delay 0 is one frame). This just occurred to me now…🙄 (but not tested).

commented

That makes sense - but I'll wait a little while, to make sure nothing is reported as broken with this :) (People tends to get two different versions if I release them too close to each other - so better to wait a few days).

I'll reopen the ticket, so I don't forget it 🙂

commented

Can you paste an example of what text you are trying with here? (Just in case something weird is happening)

commented

Normal chat text, no special chars, IIRC. It happened each time when the text was too long (i.e. two times), both times in the Guild channel.

If you cannot reproduce it, I can do some more tests in other channels.

commented

This seems to be a bug (or "inconsistency") in Blizz's Guild Chat.

If I construct a paste text with pre-split lines, i.e. simply four lines separated by a linebreak, like this…

SCR-20240903-qlqg

…then it shows exactly the same behavior:

image

In the Party chat (blue), the 4 lines always arrive in the correct order. In the Guild chat (green), they appear in some random-like order.

So, I think, the only way to work around this would be to send the lines (curr) one by one to your sendfn function, instead of all together. If this still isn't enough, then possibly with a tiny delay (eg 1 frame: C_Timer.After(0, …)).

commented

Okay, I will see what I can do 🙂
Working on a few fixes for Angrier World Quests - this issue is next on the list after that 🙂

commented

OK, could reproduce it again, and it happens only in Guild chat it seems.

This was my paste box:

SCR-20240903-phpr
Plaintext
1 abc defghijk lmnopqrs abc defghijk lmnopqrs 2 abc defghijk lmnopqrs abc defghijk lmnopqrs 3 abc defghijk lmnopqrs abc defghijk lmnopqrs 4 abc defghijk lmnopqrs abc defghijk lmnopqrs 5 abc defghijk lmnopqrs abc defghijk lmnopqrs 6 abc defghijk lmnopqrs abc defghijk lmnopqrs 7 abc defghijk lmnopqrs abc defghijk lmnopqrs 8 abc defghijk lmnopqrs abc defghijk lmnopqrs 

It gets pasted like this in the Guild chat:

SCR-20240903-phkg

You see the two posts at 17:25:37? These are the two parts of my paste box text (auto-split by PasteNG). By the numbers in the text you can see that the second part was pasted first.

If you try to explain a longish and complex thing, it can be quite confusing if the parts appear in the wrong order 😉

commented

PS:

In party chat or "say" chat, the order is OK:

image
commented

I misread your line loop, it already sends the curr one by one. This makes it easier:

This works for me:

--- /Users/tom/.tmpfs_devices/0D3B10/Tmp-4G/Paste/core.lua	2024-09-03 14:39:45.000000000 
+++ /Applications/World of Warcraft/_retail_/Interface/AddOns/Paste/core.lua	2024-09-03 20:01:37.000000000 
@@ -665,12 +665,13 @@
     StaticPopup_Show("PASTE_SLASHWARN")
     addon.slashwarned = text
     return
   end
 
   local lines = { strsplit("\n", text) }
+  local delay = 0
 
   for idx, line in ipairs(lines) do
     while line and #line > 0 do
       local curr = line
 
       if #curr > linelimit then                -- break long lines
@@ -686,13 +687,14 @@
         line = curr:sub(bpt + 1)
         curr = curr:sub(1, bpt)
       else
         line = ""
       end
 
-      sendfn(curr)
+      delay = delay + 0.1
+      C_Timer.After(delay, function() sendfn(curr) end)
     end
   end
 end
 
 StaticPopupDialogs["PASTE_SLASHWARN"] = {
   preferredIndex = 3, -- reduce the chance of UI taint
SCR-20240903-rhop

It also works with the overlong text from the previous example.

Notes:

  • This is just a quick-and-dirty test, to see if a delay does the trick. It doesn't claim to be the ultimate solution.
  • I tried it also with a delay increment of 0.05 instead of 0.1 and it did not work on my (slow) machine. So maybe safer to go even a bit higher, like 0.15 or so, to compensate for different CPU speeds
  • If this weirdness really only happens with the Guild chat (and not the Officer chat or Raid chat, etc.), then it would probably be more elegant to move the timer to the Guild function inside wherefn.
  • Sometimes, calling things from a C_Timer.After induces taint. I have never experimented with timers for chat messages, so I don't know if it is dangerous here. I can only say that in my tests I didn't get any taint errors or log entries – so far.
commented

Nobody has complained about any issues with it.
So I have moved the delay to after the C_Timer call, to avoid waiting on the first message - released as 11.0.2-20240907-1

commented

Nobody has complained about any issues with it.

Only 2 days have passed 🤭😆

But if there really are taint issues with this, the position of the timer or the actual delay won't matter anyway…
I didn't have any, but I have used PasteNG with guild chat exactly once in the 2 days since release ;)

commented

Only time will tell 🙂