Page 1 of 1

[2.0.5] remove_undo_item() indexing is backwards

Posted: Fri Oct 18, 2024 1:44 am
by robot256
This is a followup to my F10 submission about remove_undo_item() not doing anything. It actually was doing something, just not what the documentation said.

The documentation says that for LuaUndoRedoStack::remove_undo_item(index), "The index of the undo item to remove, ordered from most recent to oldest."

However, testing shows that higher indexes remove more recent items and the index does not match the behavior of get_undo_item().

Reproduction:
  1. In a new save, place a steel chest and then a wooden chest.
  2. Hover over the undo button and see the wooden chest highlighted.
  3. Run "/c game.print(serpent.block(game.player.undo_redo_stack.get_undo_item(1)))" and see that information on the wooden chest is printed, as expected because it is the most recent item.
  4. Run "/c game.player.undo_redo_stack.remove_undo_item(2)", which in theory should remove the older item from the stack, the steel chest.
  5. Hover over the undo button and see the steel chest highlighted because the more recent wooden chest was removed from the stack instead.

Re: [2.0.5] remove_undo_item() indexing is backwards

Posted: Fri Oct 18, 2024 9:55 am
by boskid
Thanks for the report. You are right, the remove_undo_item(and remove_redo_item since they share an implementation) are indexing items incorrectly. Issue is now fixed for 2.0.6

Re: [2.0.5] remove_undo_item() indexing is backwards

Posted: Tue Feb 18, 2025 4:58 pm
by protocol_1903
Has this been fixed? It doesn't look like remove_undo_item() works at all in 2.0.34

On that note, it appears that remove_undo_action works properly, (the action disappears) but it reappears if it was the only action on the item, i.e. removing all actions from an undo_item does not delete the item.

EDIT: Nevermind, it was my implementation that was weird.