Skip to content

Kotlin CLI sample crashes when space is typed #765

Open
@rjrjr

Description

@rjrjr

In Android Studio, right-click on Main.kt and choose Run.
Press the spacebar
Kaboom:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 13
	at java.lang.String.substring(String.java:1963)
	at com.squareup.sample.hellotodo.EditTextWorkflowKt.insertCharAt(EditTextWorkflow.kt:99)
	at com.squareup.sample.hellotodo.EditTextWorkflowKt.access$insertCharAt(EditTextWorkflow.kt:1)
	at com.squareup.sample.hellotodo.EditTextWorkflow$onKeystroke$1.invoke(EditTextWorkflow.kt:71)
	at com.squareup.sample.hellotodo.EditTextWorkflow$onKeystroke$1.invoke(EditTextWorkflow.kt:16)
	at com.squareup.workflow.StatefulWorkflowKt$action$2.apply(StatefulWorkflow.kt:265)
	at com.squareup.workflow.WorkflowActionKt.applyTo(WorkflowAction.kt:182)
	at com.squareup.workflow.internal.WorkflowNode$tick$1.invoke(WorkflowNode.kt:174)
	at com.squareup.workflow.internal.WorkflowNode$tick$$inlined$forEach$lambda$1.invokeSuspend(WorkflowNode.kt:196)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:270)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:79)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:54)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at com.squareup.sample.helloterminal.terminalworkflow.TerminalWorkflowRunner.run(TerminalWorkflowRunner.kt:72)
	at com.squareup.sample.hellotodo.MainKt.main(Main.kt:23)
	at com.squareup.sample.hellotodo.MainKt.main(Main.kt)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingkotlin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions