Open jcubic opened 1 month ago
The problem is with Cycle::length
, it returned array length and not how many items were in the array, removing the item is using delete data[index]
. So after each hot reload, the terminal_id
is the next value.
Changing the behavior of Cycle
breaks half of unit tests.
This is only required by hot reload, so the fix was to add id
option that replace old terminal with the same data in Cycle data structure.
With a single terminal on the page, you can use:
$('...').terminal(commands, {
id: 0
});
And history will be preserved between reloads.
Issue summary
Each time when hot reload, update the page that have the terminal new history is created.
Expected behavior
When a terminal is destroyed and created again, it should create the exact same terminal with the same history.
Steps to reproduce
cd docs && npm install && npm start
Browser and OS
N/A
Additional notes
The terminal_id needs to be updated when a terminal is destroyed.