Check for duplicates
Problem
The Workspace.undo() method takes one bool parameter named "redo" which, if false, performs the undo action as one would expect of an "undo()" method, and if true, performs a redo of the last action that was reverted using undo().
Since the name of the parameter is not visible when calling the method (e.g. undo(false)), this seems unintuitive and decreases readability and maintainability of Blockly code.
See Blockly reference.
To fix
- In
core/workspace.ts, find the undo method and give it a default value of false
This will allow users to simply call undo() to undo something, while still allowing undo(true) to redo.
If you'd like to work on this issue, please comment here so we can assign it to you. You can also read our contributing docs
Alternatives considered
-
Option 1:
Instead of just having one undo() method and a bool parameter, introduce a parameterless redo() method and remove the parameter of undo(). When using Blockly, the code would call myWorkspace.undo() or myWorkspace.redo() without any parameters.
In order to avoid duplicate code, internally this could call a "performUndoRedo" method and pass a parameter that determines if undo or redo should be performed. Ideally, the type of this parameter would be an enum, e.g. "UndoRedoAction", with two elements, e.g. "UndoRedoAction.UNDO" and "UndoRedoAction.REDO".
This could be made backward compatible by making the bool parameter optional, instead of removing it, and using false as the default value.
-
Option 2:
Use the internal implementation with the enum described above, but make it the official implementation. That means, the code using Blockly would call myWorkspace.performUndoRedo(UndoRedoAction.UNDO) or myWorkspace.performUndoRedo(UndoRedoAction.REDO).
Alternatives considered
No response
Additional context
No response
Check for duplicates
Problem
The
Workspace.undo()method takes one bool parameter named "redo" which, if false, performs the undo action as one would expect of an "undo()" method, and if true, performs a redo of the last action that was reverted usingundo().Since the name of the parameter is not visible when calling the method (e.g.
undo(false)), this seems unintuitive and decreases readability and maintainability of Blockly code.See Blockly reference.
To fix
core/workspace.ts, find theundomethod and give it a default value offalseThis will allow users to simply call
undo()to undo something, while still allowingundo(true)to redo.If you'd like to work on this issue, please comment here so we can assign it to you. You can also read our contributing docs
Alternatives considered
Option 1:
Instead of just having one
undo()method and a bool parameter, introduce a parameterlessredo()method and remove the parameter ofundo(). When using Blockly, the code would callmyWorkspace.undo()ormyWorkspace.redo()without any parameters.In order to avoid duplicate code, internally this could call a "performUndoRedo" method and pass a parameter that determines if undo or redo should be performed. Ideally, the type of this parameter would be an enum, e.g. "UndoRedoAction", with two elements, e.g. "UndoRedoAction.UNDO" and "UndoRedoAction.REDO".
This could be made backward compatible by making the bool parameter optional, instead of removing it, and using false as the default value.
Option 2:
Use the internal implementation with the enum described above, but make it the official implementation. That means, the code using Blockly would call
myWorkspace.performUndoRedo(UndoRedoAction.UNDO)ormyWorkspace.performUndoRedo(UndoRedoAction.REDO).Alternatives considered
No response
Additional context
No response