diff options
Diffstat (limited to 'core/exec.zig')
| -rw-r--r-- | core/exec.zig | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/core/exec.zig b/core/exec.zig index c1e68970..611e3430 100644 --- a/core/exec.zig +++ b/core/exec.zig @@ -766,11 +766,7 @@ pub fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { pane.command_done = false; pane.command_status = null; pane.command_pty = true; - // Its last run's errors go with it (SPEC §11). - var i: usize = 0; - while (i < p.messages.live_len) { - if (p.messages.live[i].pane == pane.serial and p.messages.live[i].kind == .@"error") p.messages.remove(i) else i += 1; - } + retireRuns(p, pane, line); pane.body.mode = .tty; // What the last program left the emulator in goes first: the // alternate screen left (only if it is there: leaving restores a @@ -794,6 +790,7 @@ pub fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { return null; }; pane.command_from = winid(p, src); + retireRuns(p, pane, line); echoCommand(p, pane, line); layout.placeNew(p, from, from, free, .command); if (refusedPlacement(p, free)) { @@ -804,6 +801,20 @@ pub fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { return free; } +/// A run of `line` starting in command pane `pane`: the errors of the +/// pane's last run go (SPEC §11), and those of an earlier run of the same +/// line in the same directory in another pane (one its job still prints +/// to, a leased one, another column's), whose next run this is. +fn retireRuns(p: *Pardes, pane: *const Pane, line: []const u8) void { + var i: usize = 0; + while (i < p.messages.live_len) { + const s = &p.messages.live[i]; + const ran = if (p.paneBySerial(s.pane)) |at| p.panes[at].? else null; + const again = if (ran) |r| if (r.command) |c| std.mem.eql(u8, c, line) and std.mem.eql(u8, r.cwdSlice(), pane.cwdSlice()) else false else false; + if (s.kind == .@"error" and (s.pane == pane.serial or again)) p.messages.remove(i) else i += 1; + } +} + /// Whether an open of a look or exec file holds `serial` from its own write /// (tree.Open.results): its client is reading that pane. pub fn leased(p: *const Pardes, serial: u32) bool { |
