aboutsummaryrefslogtreecommitdiff
path: root/readline/undo.c
diff options
context:
space:
mode:
Diffstat (limited to 'readline/undo.c')
-rw-r--r--readline/undo.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/readline/undo.c b/readline/undo.c
index eb042b2..e9369b1 100644
--- a/readline/undo.c
+++ b/readline/undo.c
@@ -1,7 +1,7 @@
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
-/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -101,23 +101,33 @@ rl_add_undo (what, start, end, text)
rl_undo_list = temp;
}
-/* Free the existing undo list. */
+/* Free an UNDO_LIST */
void
-rl_free_undo_list ()
+_rl_free_undo_list (ul)
+ UNDO_LIST *ul;
{
- UNDO_LIST *release, *orig_list;
+ UNDO_LIST *release;
- orig_list = rl_undo_list;
- while (rl_undo_list)
+ while (ul)
{
- release = rl_undo_list;
- rl_undo_list = rl_undo_list->next;
+ release = ul;
+ ul = ul->next;
if (release->what == UNDO_DELETE)
xfree (release->text);
xfree (release);
}
+}
+
+/* Free the existing undo list. */
+void
+rl_free_undo_list ()
+{
+ UNDO_LIST *release, *orig_list;
+
+ orig_list = rl_undo_list;
+ _rl_free_undo_list (rl_undo_list);
rl_undo_list = (UNDO_LIST *)NULL;
replace_history_data (-1, (histdata_t *)orig_list, (histdata_t *)NULL);
}
@@ -168,6 +178,7 @@ rl_do_undo ()
{
UNDO_LIST *release;
int waiting_for_begin, start, end;
+ HIST_ENTRY *cur, *temp;
#define TRANS(i) ((i) == -1 ? rl_point : ((i) == -2 ? rl_end : (i)))
@@ -222,6 +233,18 @@ rl_do_undo ()
release = rl_undo_list;
rl_undo_list = rl_undo_list->next;
+
+ /* If we are editing a history entry, make sure the change is replicated
+ in the history entry's line */
+ cur = current_history ();
+ if (cur && cur->data && (UNDO_LIST *)cur->data == release)
+ {
+ temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
+ xfree (temp->line);
+ FREE (temp->timestamp);
+ xfree (temp);
+ }
+
replace_history_data (-1, (histdata_t *)release, (histdata_t *)rl_undo_list);
xfree (release);