override fun handleInsert()

in gdscript/src/main/kotlin/gdscript/completion/utils/GdLookupInsertHandler.kt [16:47]


    override fun handleInsert(context: InsertionContext, item: LookupElement) {
        val editor = context.editor
        val project = editor.project
        var valueToInsert = item.getObject().toString()
        val move = valueToInsert == "()_"
        if (move) {
            valueToInsert = "()"
        }
        if (project != null) {
            val model = editor.caretModel
            val matched = toAdd(editor, valueToInsert)
            if (matched > 0) {
                model.moveToOffset(model.offset + matched)
            }
            if (valueToInsert.length - matched > 0) {
                EditorModificationUtil.insertStringAtCaret(editor, valueToInsert.substring(matched))
                PsiDocumentManager.getInstance(project).commitDocument(editor.document)
                if (valueToInsert == "()" && move) {
                    model.moveToOffset(model.offset - 1)
                    if (CodeInsightSettings.getInstance().SHOW_PARAMETER_NAME_HINTS_ON_COMPLETION)
                        ShowParameterInfoHandler.invoke(
                                project,
                                editor,
                                editor.virtualFile?.getPsiFile(project),
                                model.offset - 2,
                                null,
                                false,
                        )
                }
            }
        }
    }