Skip to content

Commit

Permalink
fix bug causing editor to close when ctrl+c pressed in shell
Browse files Browse the repository at this point in the history
  • Loading branch information
wbourne0 committed Jun 15, 2023
1 parent e31c144 commit 2124a2e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,22 @@ func openProject(dirName string) {
os.Exit(1)
}
}
cmd := exec.Command("subl", "-p", projPath)

err = exec.Command("subl", "-p", projPath).Run()
// without setsid signals from ctrl+c in shell will be forwarded to the child proc
// causing the editor to exit
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}

err = cmd.Run()
if err != nil {
fmt.Println("unable to start subl:", err.Error())
os.Exit(1)
}
} else if editor == "code" || editor == "code-oss" {
err = exec.Command(editor, dirName).Run()
cmd := exec.Command(editor, dirName)
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}

err = cmd.Run()
if err != nil {
fmt.Println("unable to start vscode:", err.Error())
os.Exit(1)
Expand Down

0 comments on commit 2124a2e

Please sign in to comment.