commit 9abbbaf58ac64c4d50b3b97ff9504c1eb7cbebad
parent 9fd901758d3877caa5fca48f9e446a13b7630193
Author: brookjeynes <me@brookjeynes.dev>
Date: Mon, 29 Jun 2026 12:58:06 +1000
fix: editor not opening with content prefilled
Signed-off-by: brookjeynes <me@brookjeynes.dev>
Diffstat:
| M | task.c | | | 30 | ++++++++++++++++-------------- |
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/task.c b/task.c
@@ -536,20 +536,22 @@ static int new_command(int argc, char *argv[], struct options *cli_args) {
return 1;
}
- // char *editor = getenv("VISUAL");
- // if (editor != NULL && strcmp(editor, "") == 0) {
- // editor = NULL;
- // }
- // if (editor == NULL) {
- // editor = getenv("EDITOR");
- // }
- //
- // if (editor == NULL || strcmp(editor, "") == 0) {
- // return 0;
- // }
-
- // execlp("sh", "sh", "-c", "exec $1 \"$2\"", "task", editor, path, NULL);
- // perror("err: failed to open editor");
+ fclose(f);
+
+ char *editor = getenv("VISUAL");
+ if (editor != NULL && strcmp(editor, "") == 0) {
+ editor = NULL;
+ }
+ if (editor == NULL) {
+ editor = getenv("EDITOR");
+ }
+
+ if (editor == NULL || strcmp(editor, "") == 0) {
+ return 0;
+ }
+
+ execlp("sh", "sh", "-c", "exec $1 \"$2\"", "task", editor, path, NULL);
+ perror("err: failed to open editor");
return 1;
}