M2
M2 copied to clipboard
Ctrl+D duplicates persistent readline history
Persistent history in terminal sessions as well as vscode using readline now works (#2819, #3403), but there's a minor issue: exiting the terminal with Ctrl+D causes the last item stored in the history to be duplicated. A few possible solutions:
- delete empty history entries before appending
- advance
lineNumberbeforeexitandrestartend the session, then switch to savinglineNumber-1lines (so Ctrl+D skips one relatively).
Overall, I've forgotten how Ctrl+D interrupts are caught and handled, so clarity there would be useful.
Another issue, raised by @MichaelABurr, is that currently the history is uncapped. libhistory provides history_truncate_file for keeping the last N entries. I'm not sure what is a good maximum, but maybe we can set a default and make sure it is adjustable in init.m2.
ps: I should note that history is not saved at all when --no-readline is passed, which is the case by default when starting M2 from Emacs.
Looking at a few other users of readline:
I'm honestly unsure if it's super necessary. Like I mentioned, M2 loads ~480 files on startup! How about something really high like 10000 as default?