Commit 991b837
chamard
·
2026-09-05 09:02:34 -0400 EDT
parent 0f50c39
fix: avoid processing unchanged OSC 7 working directories (#253)
2 files changed,
+28,
-0
+1,
-0
| ... | ... | @@ -1227,6 +1227,7 @@ pub const Daemon = struct { | |
| 1227 | 1227 | ||
| 1228 | 1228 | fn setPwd(self: *Daemon, term: *ghostty_vt.Terminal) void { | |
| 1229 | 1229 | const pwd = term.getPwd() orelse return; | |
| 1230 | + | if (std.mem.eql(u8, self.cwd, pwd)) return; | |
| 1230 | 1231 | self.setCwd(pwd); | |
| 1231 | 1232 | } | |
| 1232 | 1233 |
+27,
-0
| ... | ... | @@ -74,3 +74,30 @@ osc7_session() { | |
| 74 | 74 | [ "$status" -eq 0 ] | |
| 75 | 75 | [[ "$output" == *"/zmx spaced dir"* ]] | |
| 76 | 76 | } | |
| 77 | + | ||
| 78 | + | @test "unchanged OSC 7 is not logged again after output or queries" { | |
| 79 | + | local name=test-cwd-unchanged uri=file://localhost/tmp | |
| 80 | + | "$ZMX" run "$name" -d sh -c \ | |
| 81 | + | 'printf "\033]7;file://localhost/tmp\007cwd-ready\n"; cat' | |
| 82 | + | wait_for_output "$name" cwd-ready | |
| 83 | + | wait_for_cwd "$name" "cwd=$uri" | |
| 84 | + | ||
| 85 | + | "$ZMX" send "$name" $'ordinary-output\n' | |
| 86 | + | wait_for_output "$name" ordinary-output | |
| 87 | + | printf '\033]7;%s\007repeated-cwd\n' "$uri" | "$ZMX" print "$name" | |
| 88 | + | wait_for_output "$name" repeated-cwd | |
| 89 | + | wait_for_cwd "$name" "cwd=$uri" | |
| 90 | + | ||
| 91 | + | [ "$(grep -Fc "set cwd=$uri path=/tmp" "$ZMX_DIR/logs/$name.log")" -eq 1 ] | |
| 92 | + | } | |
| 93 | + | ||
| 94 | + | @test "OSC 7 tracks changed directories and returning to a previous directory" { | |
| 95 | + | local name=test-cwd-changes uri | |
| 96 | + | "$ZMX" run "$name" -d cat | |
| 97 | + | wait_for_session "$name" | |
| 98 | + | ||
| 99 | + | for uri in file://localhost/tmp/a%20b file://some-remote-box/home/me file://localhost/tmp/a%20b; do | |
| 100 | + | printf '\033]7;%s\007' "$uri" | "$ZMX" print "$name" | |
| 101 | + | wait_for_cwd "$name" "cwd=$uri" | |
| 102 | + | done | |
| 103 | + | } |