Fix completion for back-ticked name (KT-19863, KT-19864)
^KT-19863 Fixed ^KT-19864 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
864b90f8c0
commit
18ed031e7e
+5
-1
@@ -26,7 +26,11 @@ open class BaseDeclarationInsertHandler : InsertHandler<LookupElement> {
|
|||||||
override fun handleInsert(context: InsertionContext, item: LookupElement) {
|
override fun handleInsert(context: InsertionContext, item: LookupElement) {
|
||||||
val name = (item.`object` as? DeclarationLookupObject)?.name
|
val name = (item.`object` as? DeclarationLookupObject)?.name
|
||||||
if (name != null && !name.isSpecial) {
|
if (name != null && !name.isSpecial) {
|
||||||
context.document.replaceString(context.startOffset, context.tailOffset, name.render())
|
val startOffset = context.startOffset
|
||||||
|
if (startOffset > 0 && context.document.isTextAt(startOffset - 1, "`")) {
|
||||||
|
context.document.deleteString(startOffset - 1, startOffset)
|
||||||
|
}
|
||||||
|
context.document.replaceString(startOffset, context.tailOffset, name.render())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun `backticked`() {}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
`ba<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELEMENT: backticked
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun `backticked`() {}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
backticked()<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELEMENT: backticked
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun `backticked~name`() {}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
`ba<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELEMENT: backticked~name
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun `backticked~name`() {}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
`backticked~name`()<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELEMENT: backticked~name
|
||||||
+10
@@ -114,6 +114,16 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
|||||||
runTest("idea/idea-completion/testData/handlers/basic/KT14130.kt");
|
runTest("idea/idea-completion/testData/handlers/basic/KT14130.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("KT19863.kt")
|
||||||
|
public void testKT19863() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/KT19863.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("KT19864.kt")
|
||||||
|
public void testKT19864() throws Exception {
|
||||||
|
runTest("idea/idea-completion/testData/handlers/basic/KT19864.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("KT23627.kt")
|
@TestMetadata("KT23627.kt")
|
||||||
public void testKT23627() throws Exception {
|
public void testKT23627() throws Exception {
|
||||||
runTest("idea/idea-completion/testData/handlers/basic/KT23627.kt");
|
runTest("idea/idea-completion/testData/handlers/basic/KT23627.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user