history_save_max
This commit is contained in:
parent
512811d3a7
commit
d636696445
|
@ -106,11 +106,11 @@ history
|
|||
You need to specify the path of the history file in the editor data, then restore the persistent history by `layout_machi.editor.restore_data`. For example,
|
||||
|
||||
```
|
||||
machi_layout_data = layout_machi.editor.restore_data({ history_file = ".machi-layout" })
|
||||
machi_layout_data = layout_machi.editor.restore_data({ history_file = ".machi-layout", history_save_max = 10 })
|
||||
```
|
||||
|
||||
Then start the editor with the restored data.
|
||||
For now the last 10 commands are persisted.
|
||||
The last `history_save_max` commands are persisted.
|
||||
|
||||
## Other functions
|
||||
|
||||
|
|
|
@ -515,12 +515,11 @@ function start_editor(data)
|
|||
data.cmds[#data.cmds + 1] = current_cmd
|
||||
|
||||
if data.history_file then
|
||||
-- only save the last 10 layouts
|
||||
local file, err = io.open(data.history_file, "w")
|
||||
if err then
|
||||
print("cannot save history to " .. data.history_file)
|
||||
else
|
||||
for i = max(1, #data.cmds - 10), #data.cmds do
|
||||
for i = max(1, #data.cmds - data.history_save_max + 1), #data.cmds do
|
||||
print("save cmd " .. data.cmds[i])
|
||||
file:write(data.cmds[i] .. "\n")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue