Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Thu, 28 Jun 2018 09:10:09 +0000 (11:10 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 28 Jun 2018 09:10:09 +0000 (11:10 +0200)
source/blender/editors/space_text/text_autocomplete.c

index 9163831c333b19b38e3be12624d0d95903b86397..4f6a3bc82bac59a35fd7fbb0e95d1092b41e947b 100644 (file)
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "ED_text.h"
+#include "ED_undo.h"
 #include "ED_screen.h"
+
 #include "UI_interface.h"
 
 #include "text_format.h"
@@ -284,10 +287,11 @@ static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent *
                ED_area_tag_redraw(CTX_wm_area(C));
 
                if (texttool_suggest_first() == texttool_suggest_last()) {
-                       TextUndoBuf *utxt = NULL; // FIXME
+                       TextUndoBuf *utxt = ED_text_undo_push_init(C);
                        confirm_suggestion(st->text, utxt);
                        text_update_line_edited(st->text->curl);
                        text_autocomplete_free(C, op);
+                       ED_undo_push(C, op->type->name);
                        return OPERATOR_FINISHED;
                }
                else {
@@ -315,8 +319,6 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
 
        (void)text;
 
-       TextUndoBuf *utxt = NULL; // FIXME
-
        if (st->doplugins && texttool_text_is_active(st->text)) {
                if (texttool_suggest_first()) tools |= TOOL_SUGG_LIST;
                if (texttool_docs_get()) tools |= TOOL_DOCUMENT;
@@ -343,8 +345,10 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
                case MIDDLEMOUSE:
                        if (event->val == KM_PRESS) {
                                if (text_do_suggest_select(st, ar)) {
+                                       TextUndoBuf *utxt = ED_text_undo_push_init(C);
                                        confirm_suggestion(st->text, utxt);
                                        text_update_line_edited(st->text->curl);
+                                       ED_undo_push(C, op->type->name);
                                        swallow = 1;
                                }
                                else {
@@ -378,8 +382,10 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
                case PADENTER:
                        if (event->val == KM_PRESS) {
                                if (tools & TOOL_SUGG_LIST) {
+                                       TextUndoBuf *utxt = ED_text_undo_push_init(C);
                                        confirm_suggestion(st->text, utxt);
                                        text_update_line_edited(st->text->curl);
+                                       ED_undo_push(C, op->type->name);
                                        swallow = 1;
                                        draw = 1;
                                }
@@ -591,5 +597,6 @@ void TEXT_OT_autocomplete(wmOperatorType *ot)
        ot->poll = text_space_edit_poll;
 
        /* flags */
+       /* Undo is handled conditionally by this operator. */
        ot->flag = OPTYPE_BLOCKING;
 }