Break out non-autocomplete changes from autocomplete PR (#618)

This improves the ephemeral command runner to allow for honoring of
timeouts and proper handling of overriding the current working
directory. It also fixes some partially transparent font colors in light
mode, making them solid instead. It also updates the InputModel to be
auto-observable and utilize some getters to ensure the cmdinput is
getting updated whenever necessary state changes take place.
This commit is contained in:
Evan Simkowitz
2024-04-29 18:29:27 -07:00
committed by GitHub
parent ac91fa8596
commit c6a8797ddd
15 changed files with 362 additions and 324 deletions
+10 -3
View File
@@ -926,12 +926,11 @@ func RunCommandSimple(pk *packet.RunPacketType, sender *packet.PacketSender, fro
rcFileName = fmt.Sprintf("/dev/fd/%d", rcFileFdNum)
}
if cmd.TmpRcFileName != "" {
go func() {
time.AfterFunc(2*time.Second, func() {
// cmd.Close() will also remove rcFileName
// adding this to also try to proactively clean up after 2-seconds.
time.Sleep(2 * time.Second)
os.Remove(cmd.TmpRcFileName)
}()
})
}
fullCmdStr := pk.Command
if pk.ReturnState {
@@ -1109,6 +1108,14 @@ func RunCommandSimple(pk *packet.RunPacketType, sender *packet.PacketSender, fro
if err != nil {
return nil, err
}
if pk.Timeout > 0 {
// Cancel the command if it takes too long
time.AfterFunc(pk.Timeout, func() {
cmd.Cmd.Cancel()
cmd.Close()
})
}
return cmd, nil
}