degesch: readline fixups

When a new buffer was created automatically (channel was joined),
we didn't bother to erase the current line buffer.
This commit is contained in:
Přemysl Eric Janouch 2015-11-24 03:04:14 +01:00
parent 25282cfe23
commit e921a619b0
1 changed files with 7 additions and 6 deletions

View File

@ -226,8 +226,7 @@ input_erase (struct input *self)
(void) self;
rl_set_prompt ("");
rl_replace_line ("", 0);
rl_point = rl_mark = 0;
rl_replace_line ("", false);
rl_redisplay ();
}
@ -325,12 +324,15 @@ input_save_buffer (struct input *self, struct input_buffer *buffer)
buffer->saved_line = rl_copy_text (0, rl_end);
buffer->saved_point = rl_point;
buffer->saved_mark = rl_mark;
rl_replace_line ("", true);
if (self->prompt_shown > 0)
rl_redisplay ();
}
static void
input_restore_buffer (struct input *self, struct input_buffer *buffer)
{
// Restore the target buffer's history
if (buffer->history)
{
// history_get_history_state() just allocates a new HISTORY_STATE
@ -352,10 +354,9 @@ input_restore_buffer (struct input *self, struct input_buffer *buffer)
free (state);
}
// Try to restore the target buffer's readline state
if (buffer->saved_line)
{
rl_replace_line (buffer->saved_line, 0);
rl_replace_line (buffer->saved_line, true);
rl_point = buffer->saved_point;
rl_mark = buffer->saved_mark;
free (buffer->saved_line);
@ -441,7 +442,7 @@ input_restore (struct input *self)
hard_assert (self->saved_line);
rl_set_prompt (self->prompt);
rl_replace_line (self->saved_line, 0);
rl_replace_line (self->saved_line, false);
rl_point = self->saved_point;
rl_mark = self->saved_mark;
free (self->saved_line);