auto-complete was moving the selection.

This commit is contained in:
Campbell Barton 2011-03-14 06:48:51 +00:00
parent 4a747bebf4
commit b0a9dbf9c8
2 changed files with 12 additions and 5 deletions

@ -240,12 +240,20 @@ def autocomplete(context):
# This function isnt aware of the text editor or being an operator
# just does the autocomp then copy its results back
current_line.body, current_line.current_character, scrollback = \
intellisense.expand(
line=current_line.body,
result = intellisense.expand(
line=line,
cursor=current_line.current_character,
namespace=console.locals,
private=bpy.app.debug)
line_new = result[0]
current_line.body, current_line.current_character, scrollback = result
del result
# update sel. setting body should really do this!
ofs = len(line_new) - len(line)
sc.select_start += ofs
sc.select_end += ofs
except:
# unlikely, but this can happen with unicode errors for example.
# or if the api attribute access its self causes an error.

@ -614,12 +614,11 @@ static void rna_ConsoleLine_body_set(PointerRNA *ptr, const char *value)
ConsoleLine *ci= (ConsoleLine*)ptr->data;
int len= strlen(value);
if((len >= ci->len_alloc) || (len * 2 < ci->len_alloc) ) { /* allocate a new strnig */
if((len >= ci->len_alloc) || (len * 2 < ci->len_alloc) ) { /* allocate a new string */
MEM_freeN(ci->line);
ci->line= MEM_mallocN((len + 1) * sizeof(char), "rna_consoleline");
ci->len_alloc= len + 1;
}
memcpy(ci->line, value, len + 1);
ci->len= len;