* 'Undo' or 'Redo' the last/next user entry in the history table. * This does not modify the history table, only the pointer to the current state. * * @param {boolean} [undo=true] If set to `true`, then this function does an 'Undo', otherwise it does a 'Redo' (Optional, default: true)
(undo = true)
| 1727 | * @private |
| 1728 | */ |
| 1729 | _historyTableUndoOrRedo(undo = true) { |
| 1730 | let check; |
| 1731 | if (undo) { |
| 1732 | // Only 'undo' if there are some info to undo |
| 1733 | check = this.historyTableIndex > 0; |
| 1734 | if (check) { |
| 1735 | this.historyTableIndex--; |
| 1736 | } |
| 1737 | } else { |
| 1738 | // Only 'redo' if there are some info to redo at the end of the history table |
| 1739 | check = this.historyTableIndex + 1 < this.historyTable.length; |
| 1740 | if (check) { |
| 1741 | this.historyTableIndex++; |
| 1742 | } |
| 1743 | } |
| 1744 | |
| 1745 | if (check) { |
| 1746 | // Set the value back |
| 1747 | const undoInfo = this.historyTable[this.historyTableIndex]; |
| 1748 | this.set(undoInfo.value, null, false); // next or previous raw value |
| 1749 | |
| 1750 | // Set the selection back |
| 1751 | AutoNumericHelper.setElementSelection(this.domElement, undoInfo.start, undoInfo.end); |
| 1752 | } |
| 1753 | } |
| 1754 | |
| 1755 | /** |
| 1756 | * 'Undo' the last user entry by going back one entry in the history table. |
no test coverage detected