[geany/geany] 1b1a1d: Clear redo stack when adding undo action
Arthur Rosenstein
git-noreply at xxxxx
Wed Jan 28 14:38:45 UTC 2015
Branch: refs/heads/master
Author: Arthur Rosenstein <artros.misc at gmail.com>
Committer: Arthur Rosenstein <artros.misc at gmail.com>
Date: Sun, 10 Nov 2013 09:08:52 UTC
Commit: 1b1a1da4edfbf7168dd9afa8593cab77aca7f3a3
https://github.com/geany/geany/commit/1b1a1da4edfbf7168dd9afa8593cab77aca7f3a3
Log Message:
-----------
Clear redo stack when adding undo action
This fixes a bug in Geany where modifying the document does not clear the
redo actions stack.
Modified Paths:
--------------
src/document.c
Modified: src/document.c
23 lines changed, 18 insertions(+), 5 deletions(-)
===================================================================
@@ -104,6 +104,7 @@ typedef struct
static void document_undo_clear_stack(GTrashStack **stack);
static void document_undo_clear(GeanyDocument *doc);
+static void document_undo_add_internal(GeanyDocument *doc, guint type, gpointer data);
static void document_redo_add(GeanyDocument *doc, guint type, gpointer data);
static gboolean remove_page(guint page_num);
@@ -2515,8 +2516,11 @@ void document_undo_clear(GeanyDocument *doc)
}
-/* note: this is called on SCN_MODIFIED notifications */
-void document_undo_add(GeanyDocument *doc, guint type, gpointer data)
+/* Adds an undo action without clearing the redo stack. This function should
+ * not be called directly, generally (use document_undo_add() instead), but is
+ * used by document_redo() in order not to erase the redo stack while moving
+ * an action from the redo stack to the undo stack. */
+void document_undo_add_internal(GeanyDocument *doc, guint type, gpointer data)
{
undo_action *action;
@@ -2535,6 +2539,15 @@ void document_undo_add(GeanyDocument *doc, guint type, gpointer data)
ui_update_popup_reundo_items(doc);
}
+/* note: this is called on SCN_MODIFIED notifications */
+void document_undo_add(GeanyDocument *doc, guint type, gpointer data)
+{
+ /* Clear the redo actions stack before adding the undo action. */
+ document_undo_clear_stack(&doc->priv->redo_actions);
+
+ document_undo_add_internal(doc, type, data);
+}
+
gboolean document_can_undo(GeanyDocument *doc)
{
@@ -2646,14 +2659,14 @@ void document_redo(GeanyDocument *doc)
{
case UNDO_SCINTILLA:
{
- document_undo_add(doc, UNDO_SCINTILLA, NULL);
+ document_undo_add_internal(doc, UNDO_SCINTILLA, NULL);
sci_redo(doc->editor->sci);
break;
}
case UNDO_BOM:
{
- document_undo_add(doc, UNDO_BOM, GINT_TO_POINTER(doc->has_bom));
+ document_undo_add_internal(doc, UNDO_BOM, GINT_TO_POINTER(doc->has_bom));
doc->has_bom = GPOINTER_TO_INT(action->data);
ui_update_statusbar(doc, -1);
@@ -2662,7 +2675,7 @@ void document_redo(GeanyDocument *doc)
}
case UNDO_ENCODING:
{
- document_undo_add(doc, UNDO_ENCODING, g_strdup(doc->encoding));
+ document_undo_add_internal(doc, UNDO_ENCODING, g_strdup(doc->encoding));
document_set_encoding(doc, (const gchar*)action->data);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list