in remote-fixtures/src/main/kotlin/com/intellij/remoterobot/fixtures/TextEditorFixture.kt [196:219]
fun replaceText(textInEditor: String, raplaceWithText: String) {
val stringBeginOffset = this.text.indexOf(textInEditor)
if (stringBeginOffset != -1) {
val stringEndOffset = textInEditor.length + stringBeginOffset
scrollToOffset(stringBeginOffset)
runJs("""
// import package with WriteCommandAction
importPackage(com.intellij.openapi.command)
const editor = local.get('editor')
const document = local.get('document')
const project = editor.getProject()
WriteCommandAction.runWriteCommandAction(project, new Runnable({
run: function () {
document.replaceString($stringBeginOffset, $stringEndOffset, '$raplaceWithText')
}
}))
""")
} else {
throw StringIndexOutOfBoundsException("text: '$textInEditor' was not found")
}
}