From 6b5b95bb4e269a1bd740707e27eae09983b84268 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 3 Jan 2015 13:03:13 -0300 Subject: -added new code completion guess locations, closes #1032 -moved commandline fix to mingw-only, should fix #1064 --- scene/gui/text_edit.cpp | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'scene') diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 933895a207..8afcbf3283 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3274,19 +3274,41 @@ void TextEdit::_update_completion_candidates() { String s; - - while(cofs>0 && l[cofs-1]>32 && _is_completable(l[cofs-1])) { - s=String::chr(l[cofs-1])+s; - if (l[cofs-1]=='\'' || l[cofs-1]=='"') - break; - - cofs--; + + //look for keywords first + + bool pre_keyword=false; + + if (cofs>0 && l[cofs-1]==' ') { + int kofs=cofs-1; + String kw; + while (kofs>=0 && l[kofs]==' ') + kofs--; + + while(kofs>=0 && l[kofs]>32 && _is_completable(l[kofs])) { + kw=String::chr(l[kofs])+kw; + kofs--; + } + + pre_keyword=keywords.has(kw); + print_line("KW "+kw+"? "+itos(pre_keyword)); + + } else { + + + while(cofs>0 && l[cofs-1]>32 && _is_completable(l[cofs-1])) { + s=String::chr(l[cofs-1])+s; + if (l[cofs-1]=='\'' || l[cofs-1]=='"') + break; + + cofs--; + } } - + update(); - if (s=="" && (cofs==0 || !completion_prefixes.has(String::chr(l[cofs-1])))) { + if (!pre_keyword && s=="" && (cofs==0 || !completion_prefixes.has(String::chr(l[cofs-1])))) { //none to complete, cancel _cancel_completion(); return; -- cgit v1.2.3