-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persistent readline history #620
Persistent readline history #620
Conversation
Yeees, looking forward to using this. \o/ |
include/tig/prompt.h
Outdated
@@ -46,6 +46,8 @@ struct input { | |||
enum input_status prompt_default_handler(struct input *input, struct key *key); | |||
char *read_prompt_incremental(const char *prompt, bool edit_mode, bool allow_empty, input_handler handler, void *data); | |||
char *read_prompt(const char *prompt); | |||
const char *prompt_histfile(void); | |||
void prompt_teardown(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor nit, these don't have to be exported.
src/prompt.c
Outdated
@@ -466,10 +467,44 @@ read_prompt(const char *prompt) | |||
return line; | |||
} | |||
|
|||
const char * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and both can be declared static
.
Very nice. |
b180466
to
c29f5da
Compare
src/prompt.c
Outdated
prompt_teardown(void) | ||
{ | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to mention that these can be removed. But I can do that after merge.
or $XDG_DATA_HOME/tig/history
c29f5da
to
54ce4e4
Compare
Persist readline history to
~/.tig_history
or$XDG_DATA_HOME/tig/history
.Arguably the
$XDG_DATA_HOME
part doesn't belong inprompt.c
but this does keep#ifdef HAVE_READLINE
tucked into a single file.It might be preferable to persist only the "search" part of the history as
less
does. Certainly that's the part of the feature I intend to use. However, all readline inputs are currently merged in the volatile history, and I wanted to avoid changing existing UI.Another desirable refinement would be to take
HISTORY_SIZE
from a~/.tigrc
option, and support disabling persistent history when set to zero.It doesn't seem practical to provide test coverage as there isn't a reliable way to inspect the binary for its compile-time readline configuration.