From c3a9fc5efb4a81f6efb28d0c787e17503deaee46 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 11 Aug 2019 20:50:02 +1000 Subject: Text: support comment without selection D5451 by @Poulpator with fixes. --- source/blender/editors/space_text/text_ops.c | 42 +++++++++++++--------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'source/blender/editors/space_text/text_ops.c') diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index a8af9c73bf2..e1550deb659 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1217,36 +1217,34 @@ static int text_comment_exec(bContext *C, wmOperator *op) Text *text = CTX_data_edit_text(C); int type = RNA_enum_get(op->ptr, "type"); - if (txt_has_sel(text)) { - text_drawcache_tag_update(CTX_wm_space_text(C), 0); + text_drawcache_tag_update(CTX_wm_space_text(C), 0); - ED_text_undo_push_init(C); + ED_text_undo_push_init(C); + if (txt_has_sel(text)) { txt_order_cursors(text, false); + } - switch (type) { - case 1: + switch (type) { + case 1: + txt_comment(text); + break; + case -1: + txt_uncomment(text); + break; + default: + if (txt_uncomment(text) == false) { txt_comment(text); - break; - case -1: - txt_uncomment(text); - break; - default: - if (txt_uncomment(text) == false) { - txt_comment(text); - } - break; - } - - text_update_edited(text); + } + break; + } - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); + text_update_edited(text); - return OPERATOR_FINISHED; - } + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); - return OPERATOR_CANCELLED; + return OPERATOR_FINISHED; } void TEXT_OT_comment_toggle(wmOperatorType *ot) -- cgit v1.2.3