From f39aa170586e2d713488ad81eaec46893db0f0fe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 9 Jan 2016 10:03:30 +1100 Subject: Text Editor: Autocomplete suggestion wrap-around D1716 by @someonewithpc --- .../blender/editors/space_text/text_autocomplete.c | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/space_text') diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index 1637ae14892..2db2137784a 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -447,9 +447,15 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e texttool_suggest_select(texttool_suggest_first()); } else { - while (sel && sel != texttool_suggest_last() && sel->next && scroll--) { - texttool_suggest_select(sel->next); - sel = sel->next; + while (sel && scroll--) { + if (sel != texttool_suggest_last() && sel->next) { + texttool_suggest_select(sel->next); + sel = sel->next; + } + else { + texttool_suggest_select(texttool_suggest_first()); + sel = texttool_suggest_first(); + } } } text_pop_suggest_list(); @@ -471,9 +477,15 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e } else if (tools & TOOL_SUGG_LIST) { SuggItem *sel = texttool_suggest_selected(); - while (sel && sel != texttool_suggest_first() && sel->prev && scroll--) { - texttool_suggest_select(sel->prev); - sel = sel->prev; + while (sel && scroll--) { + if (sel != texttool_suggest_first() && sel->prev) { + texttool_suggest_select(sel->prev); + sel = sel->prev; + } + else { + texttool_suggest_select(texttool_suggest_last()); + sel = texttool_suggest_last(); + } } text_pop_suggest_list(); swallow = 1; -- cgit v1.2.3