Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-04-21 10:50:01 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-04-21 12:09:06 +0300
commite36092fa8b8d2d2f019ecaf9fec76c80ab197314 (patch)
treea43c8922eac378934b6e55862af413daf41f7a72
parent34059fbdf3234c492aeed7ee4e909ca603fd03c8 (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.
-rw-r--r--source/blender/editors/space_text/text_ops.c20
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);