diff options
author | Campbell Barton <campbell@blender.org> | 2022-02-22 11:59:31 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-02-22 11:59:31 +0300 |
commit | 0cfcb261b1e3b04358ee5608b6d3b6e3612b0bf9 (patch) | |
tree | 739375ad50e4bb06f3366ad463c66cbbbe35f053 /source | |
parent | 765735844711294a2354521f41464429bed1db7c (diff) | |
parent | 0ad4d2694bae7f4db551138ec79a46f8f7e57bba (diff) |
Merge branch 'blender-v3.1-release'
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_console/console_ops.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index ba0b3a59e24..3fba069879b 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -456,7 +456,18 @@ void CONSOLE_OT_insert(wmOperatorType *ot) static int console_indent_or_autocomplete_exec(bContext *C, wmOperator *UNUSED(op)) { ConsoleLine *ci = console_history_verify(C); - bool text_before_cursor = ci->cursor != 0 && !ELEM(ci->line[ci->cursor - 1], ' ', '\t'); + bool text_before_cursor = false; + + /* Check any text before cursor (not just the previous character) as is done for + * #TEXT_OT_indent_or_autocomplete because Python auto-complete operates on import + * statements such as completing possible sub-modules: `from bpy import `. */ + for (int i = 0; i < ci->cursor; i += BLI_str_utf8_size_safe(&ci->line[i])) { + if (!ELEM(ci->line[i], ' ', '\t')) { + text_before_cursor = true; + break; + } + } + if (text_before_cursor) { WM_operator_name_call(C, "CONSOLE_OT_autocomplete", WM_OP_INVOKE_DEFAULT, NULL); } |