diff options
Diffstat (limited to 'src/ScintillaBase.cxx')
| -rw-r--r-- | src/ScintillaBase.cxx | 29 | 
1 files changed, 11 insertions, 18 deletions
| diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 35aa1c49e..1cf146c06 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -193,6 +193,13 @@ void ScintillaBase::AutoCompleteDoubleClick(void *p) {  	sci->AutoCompleteCompleted();  } +void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) { +	UndoGroup ug(pdoc); +	pdoc->DeleteChars(startPos, removeLen); +	pdoc->InsertString(startPos, text, textLen); +	SetEmptySelection(startPos + textLen); +} +  void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {  	//Platform::DebugPrintf("AutoComplete %s\n", list);  	ct.CallTipCancel(); @@ -202,17 +209,11 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {  			const char *typeSep = strchr(list, ac.GetTypesep());  			int lenInsert = typeSep ?   				static_cast<int>(typeSep-list) : static_cast<int>(strlen(list)); -			UndoGroup ug(pdoc);  			if (ac.ignoreCase) { -				SetEmptySelection(sel.MainCaret() - lenEntered); -				pdoc->DeleteChars(sel.MainCaret(), lenEntered); -				SetEmptySelection(sel.MainCaret()); -				pdoc->InsertString(sel.MainCaret(), list, lenInsert); -				SetEmptySelection(sel.MainCaret() + lenInsert); +				// May need to convert the case before invocation, so remove lenEntered characters +				AutoCompleteInsert(sel.MainCaret() - lenEntered, lenEntered, list, lenInsert);  			} else { -				SetEmptySelection(sel.MainCaret()); -				pdoc->InsertString(sel.MainCaret(), list + lenEntered, lenInsert - lenEntered); -				SetEmptySelection(sel.MainCaret() + lenInsert - lenEntered); +				AutoCompleteInsert(sel.MainCaret(), 0, list + lenEntered, lenInsert - lenEntered);  			}  			ac.Cancel();  			return; @@ -357,15 +358,7 @@ void ScintillaBase::AutoCompleteCompleted() {  		endPos = pdoc->ExtendWordSelect(endPos, 1, true);  	if (endPos < firstPos)  		return; -	UndoGroup ug(pdoc); -	if (endPos != firstPos) { -		pdoc->DeleteChars(firstPos, endPos - firstPos); -	} -	SetEmptySelection(ac.posStart); -	if (item != -1) { -		pdoc->InsertCString(firstPos, selected.c_str()); -		SetEmptySelection(firstPos + static_cast<int>(selected.length())); -	} +	AutoCompleteInsert(firstPos, endPos - firstPos, selected.c_str(), static_cast<int>(selected.length()));  	SetLastXChosen();  } | 
