From e921a619b0fab58bff7a753c991839843b096191 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Tue, 24 Nov 2015 03:04:14 +0100
Subject: degesch: readline fixups
When a new buffer was created automatically (channel was joined),
we didn't bother to erase the current line buffer.
---
degesch.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/degesch.c b/degesch.c
index 9b47373..2ef07db 100644
--- a/degesch.c
+++ b/degesch.c
@@ -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);
--
cgit v1.2.3-70-g09d2