diff options
author | Campbell Barton <campbell@blender.org> | 2022-04-21 10:50:01 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-04-21 10:56:56 +0300 |
commit | c342b3cede9476b4279c0f13f1ba2b068fed4cb9 (patch) | |
tree | e85384c2b1d2fadef19f2def48ddc655598c9109 /source/blender/editors/space_text | |
parent | 4d9ddb4a774dc214d99c44457abb7a14c9686c27 (diff) |
Fix T95932: Auto-close text breaks outliner drag-n-drop
Text inserted via TEXT_OT_insert would always have auto-close
logic applies which interfered any insertion of literal strings
containing brackets.
Now auto-closing brackets is restricted to characters read from
events from the operators invoke functions.
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 3f1483bbd03..753f82e483e 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -3459,12 +3459,6 @@ static int text_insert_exec(bContext *C, wmOperator *op) while (str[i]) { code = BLI_str_utf8_as_unicode_step(str, str_len, &i); done |= txt_add_char(text, code); - if (U.text_flag & USER_TEXT_EDIT_AUTO_CLOSE) { - if (text_closing_character_pair_get(code)) { - done |= txt_add_char(text, text_closing_character_pair_get(code)); - txt_move_left(text, false); - } - } } } @@ -3484,6 +3478,7 @@ static int text_insert_exec(bContext *C, wmOperator *op) static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + uint auto_close_char = 0; int ret; /* NOTE: the "text" property is always set from key-map, @@ -3510,10 +3505,23 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event) } str[len] = '\0'; RNA_string_set(op->ptr, "text", str); + + if (U.text_flag & USER_TEXT_EDIT_AUTO_CLOSE) { + auto_close_char = BLI_str_utf8_as_unicode(str); + } } ret = text_insert_exec(C, op); + if ((ret == OPERATOR_FINISHED) && (auto_close_char != 0)) { + const uint auto_close_match = text_closing_character_pair_get(auto_close_char); + if (auto_close_match != 0) { + Text *text = CTX_data_edit_text(C); + txt_add_char(text, auto_close_match); + txt_move_left(text, false); + } + } + /* run the script while editing, evil but useful */ if (ret == OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit) { text_run_script(C, NULL); |