Completion: better space key handling

This commit is contained in:
Valentin Kipyatkov
2014-11-14 14:25:10 +03:00
parent 656ed01b94
commit 03b3cf7480
2 changed files with 3 additions and 5 deletions
@@ -108,9 +108,6 @@ object NamedParametersCompletion {
editor.getDocument().replaceString(context.getStartOffset(), context.getTailOffset(), text)
editor.getCaretModel().moveToOffset(context.getStartOffset() + text.length)
if (context.getCompletionChar() == ' ') {
context.setAddCompletionChar(false)
}
WithTailInsertHandler.eqTail().postHandleInsert(context, item)
}
}
@@ -35,7 +35,8 @@ class WithTailInsertHandler(val tailText: String,
}
fun postHandleInsert(context: InsertionContext, item: LookupElement) {
if (tailText == context.getCompletionChar().toString()) {
val completionChar = context.getCompletionChar()
if (completionChar == tailText.singleOrNull() || (spaceAfter && completionChar == ' ')) {
context.setAddCompletionChar(false)
}
//TODO: what if completion char is different?
@@ -44,7 +45,7 @@ class WithTailInsertHandler(val tailText: String,
PsiDocumentManager.getInstance(context.getProject()).doPostponedOperationsAndUnblockDocument(document)
var tailOffset = context.getTailOffset()
if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR && item.getUserData(KEEP_OLD_ARGUMENT_LIST_ON_TAB_KEY) != null) {
if (completionChar == Lookup.REPLACE_SELECT_CHAR && item.getUserData(KEEP_OLD_ARGUMENT_LIST_ON_TAB_KEY) != null) {
val offset = context.getOffsetMap().getOffset(SmartCompletion.OLD_ARGUMENTS_REPLACEMENT_OFFSET)
if (offset != -1) tailOffset = offset
}