Defer level validation while editors are open
This commit is contained in:
@@ -388,11 +388,16 @@ fun GitHugApp() {
|
||||
fun applyCommandResult(raw: String, newRepo: RepoState, lines: List<String>, echoCommand: Boolean) {
|
||||
val startedAt = System.nanoTime()
|
||||
val levelForResult = currentLevel
|
||||
val solvedAfterCommand = levelForResult.validator(newRepo, raw)
|
||||
val validationBlockedByEditor = editorState != null || gitMessageEditorState != null
|
||||
val solvedAfterCommand = if (validationBlockedByEditor) {
|
||||
false
|
||||
} else {
|
||||
levelForResult.validator(newRepo, raw)
|
||||
}
|
||||
val wasAlreadyCompleted = currentLevel.id in completedLevels
|
||||
AppLog.d(
|
||||
"GitHugApp",
|
||||
"Command='$raw' level=${levelForResult.id} solved=$solvedAfterCommand alreadyCompleted=$wasAlreadyCompleted " +
|
||||
"Command='$raw' level=${levelForResult.id} solved=$solvedAfterCommand validationBlockedByEditor=$validationBlockedByEditor alreadyCompleted=$wasAlreadyCompleted " +
|
||||
"completedBefore=${completedLevels.sorted()} outputLineCount=${lines.size} repo=${newRepo.diagnosticSnapshot()}",
|
||||
)
|
||||
val newOutput = buildList {
|
||||
@@ -519,14 +524,13 @@ fun GitHugApp() {
|
||||
invocation = state.invocation,
|
||||
message = state.content,
|
||||
)
|
||||
gitMessageEditorState = null
|
||||
applyCommandResult(state.invocation.command, result.repo, result.outputLines, echoCommand = false)
|
||||
result.nextEditor?.let { nextEditor ->
|
||||
gitMessageEditorState = GitMessageEditorState(
|
||||
gitMessageEditorState = result.nextEditor?.let { nextEditor ->
|
||||
GitMessageEditorState(
|
||||
invocation = nextEditor.invocation,
|
||||
content = nextEditor.content,
|
||||
)
|
||||
}
|
||||
applyCommandResult(state.invocation.command, result.repo, result.outputLines, echoCommand = false)
|
||||
}
|
||||
|
||||
fun runCommand() {
|
||||
|
||||
Reference in New Issue
Block a user