mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-22 15:51:33 +00:00
Fix quote handler for character literals
#KT-12385 Fixed
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user