Closed rben01 closed 1 week ago
Two questions about history, the first of which may apply to current forever-history as well. I wanted some clarity on differences between the forever-history and the session history, in particular prioritizing runnability of the resulting session history file.
fn f(x) = x*y\nwhere y = 3m
(backslash-escaped) but this will not parse when reading the file again. This seems fine for the forever-history (odds are no one will run it, it's just there for searching) but session history may well be run as a file. I'm thinking insert an actual newline (which is what currently happens in this PR), not an escaped newline, in the session history file so that the file remains runnable. The above function definition would then take two lines.Thank you for this. It might be two weeks before I can do a full review.
Regarding your points:
Good question. In my opinion, the global history file format is an implementation detail. No one is supposed to make use of the fact that they could be directly executed (except for the newline problem). And I also don't see a use case for that. So is history retrieval works for those multiline inputs, then everything is fine. If that has problems as well, we can also think about changing the format.
For the session history: yes. I would also simply save this as if it had been entered in multiple lines (which is not always possible, but..).
Commands should definitely not go into the session history. I'm not even sure what we do for the global history, but thinking about it, I guess it makes sense to include them there. Users might be surprised if they enter something like "info au", and then use up-arrow to get back the "info au" in order to change it to "info as", for example.
Currently commands are saved to global history due to https://github.com/sharkdp/numbat/blob/b175c315aee8eede9c481ac8e1b444b79d24867b/numbat-cli/src/main.rs#L347-L348 I agree this is the right call. Given that we're in agreement about the utility of the session history file, I'll leave the implementation more or less as is and just think about cleaning up any tidbits. (For instance I don't like that I've got parse_and_evaluate
taking an owned input just to be able to add it to the history; will think about how to restructure this.)
I've merged this all into the commands
pull request.
This is branched from
master
, not fromcommands
, so as to let it evolve in parallel and get feedback on design independently ofcommands
. Once merged intomaster
, I'll pullmaster
intocommands
and update per-session history saving to work with theCommand
framework.