repl: add .clearhistory command#64450
Conversation
Add a `.clearhistory` REPL command that clears the in-memory session history and truncates the persisted history file when one is configured. Any pending debounced flush is cancelled first so it cannot rewrite the file after it has been cleared. Fixes: nodejs#63905 Signed-off-by: Paul Bouchon <mail@bitpshr.net>
|
This feels a bit off to me. The functionality makes sense, I could see wanting this. But I'm not sure if it's clear when I'd want this vs |
|
@bnb good call. A few options:
I lean toward |
|
@bnb This functionality will help users to remove commands/contents from previous sessions if they are trying to use same variables or functions with different purpose in subsequent new sessions. Without this functionality user will have to delete/clear contents of the history file to achieve the same. I would also agree that the name can be changed since it is quite similar to that of |
This pull request adds a
.clearhistoryREPL command that clears the current session history, both in memory and in the persistent history file when one is configured.It clears the in-memory history array, resets the navigation index, and truncates the backing file through the open handle. Any pending debounced flush is cancelled first so it cannot rewrite the file after it has been cleared.
Fixes: #63905