Fix quote handler for character literals

#KT-12385 Fixed
This commit is contained in:
Dmitry Jemerov
2016-11-18 13:11:40 +01:00
parent b742c8a63d
commit 2fe2e1802e
2 changed files with 5 additions and 2 deletions

View File

@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.idea.editor
import com.intellij.codeInsight.editorActions.QuoteHandler
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.highlighter.HighlighterIterator
import com.intellij.psi.tree.IElementType
import org.jetbrains.kotlin.lexer.KtTokens
class KotlinQuoteHandler : QuoteHandler {
@@ -40,7 +39,7 @@ class KotlinQuoteHandler : QuoteHandler {
override fun isOpeningQuote(iterator: HighlighterIterator, offset: Int): Boolean {
val tokenType = iterator.tokenType
if (tokenType == KtTokens.OPEN_QUOTE) {
if (tokenType == KtTokens.OPEN_QUOTE || tokenType == KtTokens.CHARACTER_LITERAL) {
val start = iterator.start
return offset == start
}

View File

@@ -552,6 +552,10 @@ class TypedHandlerTest : LightCodeInsightTestCase() {
checkResultByText("val a: List<Set<Int>><caret>")
}
fun testCharClosingQuote() {
doCharTypeTest('\'', "val c = <caret>", "val c = ''")
}
private fun doCharTypeTest(ch: Char, beforeText: String, afterText: String) {
LightPlatformCodeInsightTestCase.configureFromFileText("a.kt", beforeText.trimMargin())
EditorTestUtil.performTypingAction(LightPlatformCodeInsightTestCase.getEditor(), ch)