[API] ReplaceColor call only works once per transaction

I have this plugin for Aseprite (Git repo). It calls the ReplaceColor command multiple times to recolor all pixels in an image, so the image can be used with the shaders in a game I’m developing. All of these calls are wrapped inside of a transaction, so that it counts as one action in the undo history.

After the September update to Aseprite, this plugin no longer works. Now, the first ReplaceColor call inside the transaction is the only one that runs. All other calls appear to be ignored. If I run the code without the transaction, it replaces all the colors like its supposed to.

Obviously, removing the transaction can’t work as a fix. It makes it so there are dozens of actions on the undo stack. This makes it so the operation runs far slower and is far harder to reverse.

Here’s some additional info if it helps.
Aseprite Version: 1.3.15.5
OS: Linux Mint 21.3 Cinnamon, Windows 10 (happens on both OSes)

I now have a minimal example of this bug, using this image as a test.

image

When the following script is run, the entire image becomes yellow.

do
    app.command.ReplaceColor{
        ui = false,
        from = Color(255, 0, 0),
        to = Color(255, 255, 0),
        tolerance = 0,
    }
    app.command.ReplaceColor{
        ui = false,
        from = Color(0, 255, 0),
        to = Color(255, 255, 0),
        tolerance = 0,
    }
    app.command.ReplaceColor{
        ui = false,
        from = Color(0, 0, 255),
        to = Color(255, 255, 0),
        tolerance = 0,
    }
end

This script should also turn the entire image yellow, but it doesn’t. Instead, it only turns the red square yellow.

do
    app.transaction(
        "Replace Color Test",
        function()
            app.command.ReplaceColor{
                ui = false,
                from = Color(255, 0, 0),
                to = Color(255, 255, 0),
                tolerance = 0,
            }
            app.command.ReplaceColor{
                ui = false,
                from = Color(0, 255, 0),
                to = Color(255, 255, 0),
                tolerance = 0,
            }
            app.command.ReplaceColor{
                ui = false,
                from = Color(0, 0, 255),
                to = Color(255, 255, 0),
                tolerance = 0,
            }
        end
    )
end

I have also opened an issue on GitHub for this.