Open patch hunk editor for git add -p edit command

This commit is contained in:
Joe Tretter
2026-05-18 21:10:17 -05:00
parent 4c5d68c1cb
commit ed0b81e587
6 changed files with 121 additions and 4 deletions

View File

@@ -405,10 +405,15 @@ fun GitHugApp() {
fun openGitMessageEditor(invocation: GitEditorInvocation) {
val initialContent = runtime.gitEditorInitialContent(currentLevel, repo, invocation)
val openedMessage = when (invocation.kind) {
GitEditorCommandKind.REBASE_TODO -> "Opened Git rebase editor"
GitEditorCommandKind.PATCH_HUNK -> "Opened Git patch editor"
else -> "Opened Git message editor"
}
output = buildList {
addAll(output)
add("$ ${invocation.command}")
add(if (invocation.kind == GitEditorCommandKind.REBASE_TODO) "Opened Git rebase editor" else "Opened Git message editor")
add(openedMessage)
}
gitMessageEditorState = GitMessageEditorState(
invocation = invocation.copy(initialContent = initialContent),
@@ -474,6 +479,12 @@ fun GitHugApp() {
return
}
val patchHunkEditorInvocation = GitSandboxEngine.parsePatchHunkEditorInvocation(repo, raw)
if (patchHunkEditorInvocation != null) {
openGitMessageEditor(patchHunkEditorInvocation)
return
}
val (newRepo, lines) = runtime.execute(currentLevel, repo, raw)
applyCommandResult(raw, newRepo, lines, echoCommand = !isInteractiveInput)
}