From c76a9e403ab6b0759261b5211a370e8314fb4c94 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 18 Apr 2022 20:39:06 -0400 Subject: better editor support --- more.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/more.c b/more.c index 02d3e07..b126c35 100644 --- a/more.c +++ b/more.c @@ -95,7 +95,7 @@ static struct more_file more_invoke_editor(struct more_file *mf) } char line[64]; - snprintf(line, sizeof(line), "%zd", mf->topline); + snprintf(line, sizeof(line), "%zd", mf->topline + 1); char *argv[] = { editor, "-c", line, mf->path, NULL }; char *base = editor; @@ -116,11 +116,18 @@ static struct more_file more_invoke_editor(struct more_file *mf) pid_t pid; if (posix_spawnp(&pid, editor, NULL, NULL, argv, environ) == 0) { char *path = strdup(mf->path); + size_t line = mf->topline; more_close(mf); + waitpid(pid, NULL, 0); + ret = more_open(path); + ret.topline = line; free(path); + } else { + wprintw(more_status, "%s %s: %s\n", editor, mf->path, strerror(errno)); } + reset_prog_mode(); return ret; @@ -314,7 +321,7 @@ static int more(const char *path) break; case 'v': - more_invoke_editor(&mf); + mf = more_invoke_editor(&mf); break; case '=': -- cgit v1.2.1