[Bf-blender-cvs] [63f525bae33] master: Fix text editor auto-complete refinement feature
Campbell Barton
noreply at git.blender.org
Fri Oct 2 09:45:00 CEST 2020
Commit: 63f525bae3301c4d43bc62576772f42786173cd2
Author: Campbell Barton
Date: Fri Oct 2 17:23:34 2020 +1000
Branches: master
https://developer.blender.org/rB63f525bae3301c4d43bc62576772f42786173cd2
Fix text editor auto-complete refinement feature
Left/right arrow keys can refine the completion,
this wasn't redrawing and there was an off-by-one error checking
the next character.
===================================================================
M source/blender/editors/space_text/text_autocomplete.c
===================================================================
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index e754c143718..7d53f2a66cd 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -328,6 +328,7 @@ static int doc_scroll = 0;
static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
+ /* NOTE(campbell): this code could be refactored or rewritten. */
SpaceText *st = CTX_wm_space_text(C);
ScrArea *area = CTX_wm_area(C);
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
@@ -425,6 +426,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
if (event->ctrl) {
texttool_suggest_clear();
retval = OPERATOR_CANCELLED;
+ draw = 1;
}
else {
/* Work out which char we are about to delete/pass */
@@ -433,15 +435,19 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
if ((ch == '_' || !ispunct(ch)) && !text_check_whitespace(ch)) {
get_suggest_prefix(st->text, -1);
text_pop_suggest_list();
+ txt_move_left(st->text, false);
+ draw = 1;
}
else {
texttool_suggest_clear();
retval = OPERATOR_CANCELLED;
+ draw = 1;
}
}
else {
texttool_suggest_clear();
retval = OPERATOR_CANCELLED;
+ draw = 1;
}
}
}
@@ -457,23 +463,28 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
if (event->ctrl) {
texttool_suggest_clear();
retval = OPERATOR_CANCELLED;
+ draw = 1;
}
else {
/* Work out which char we are about to pass */
if (st->text->curl && st->text->curc < st->text->curl->len) {
- char ch = st->text->curl->line[st->text->curc + 1];
+ char ch = st->text->curl->line[st->text->curc];
if ((ch == '_' || !ispunct(ch)) && !text_check_whitespace(ch)) {
get_suggest_prefix(st->text, 1);
text_pop_suggest_list();
+ txt_move_right(st->text, false);
+ draw = 1;
}
else {
texttool_suggest_clear();
retval = OPERATOR_CANCELLED;
+ draw = 1;
}
}
else {
texttool_suggest_clear();
retval = OPERATOR_CANCELLED;
+ draw = 1;
}
}
}
More information about the Bf-blender-cvs
mailing list