# external file updates: a write from outside pardes lands in an open pane # that has no unsaved edits, committed like any other edit; a pane WITH # unsaved edits keeps them and says the file changed on disk (File.changed). # # The writer must be a STRANGER to the editor. This script used to have a # pardes PANE run the write, which proved much less than it looked: that # shell's own pty output wakes the loop and paints a frame, so the reload # could be riding on the keystroke's frame instead of on the watch. `run` is a # child of the RUNNER — nothing it does reaches an app pty — and every # assertion below it is a `wait`, which only READS the pty. So between the # write and the reload the app receives no keystroke, no resize, no mouse: if # the watch does not wake the loop by itself, these waits time out. # # Two files in two directories, written the two ways files actually change: # w.txt in place (CLOSE_WRITE) and sub/s.txt by rename-over, which is what # `zig fmt`, `git checkout` and every editor's atomic save do (MOVED_TO, and # a new inode — the reason the mark is on the directory). dirmk sub file w.txt line 1\nline 2\n/tmp/pardes-snap/filewatch/cwd/sub/s.txt\nline 4\nline 5\nline 6\nline 7\nline 8\nline 9\nline 10\nline 11\nline 12\n lines sub/s.txt 8 # Builtins announce themselves by default, and an announcement is a band at # the top of the body -- which moves every row this script clicks. What the # verbs do is what is under test, not the announcement. config Verbose off start 31 210 -n 1 wait 8000 w.txt stable 700 20000 # open w.txt as a file pane: type the name into the shell, right-click it press left 5 9 release left 5 9 stable 400 5000 key i text w.txt key esc settle 100 press right 6 9 release right 6 9 wait 10000 line 4 stable 700 15000 # ...and open sub/s.txt from the path sitting on line 3 of that pane, so the # second watched pane is in a DIFFERENT directory from the first press right 20 10 release right 20 10 wait 10000 line 8 stable 700 15000 # an UNSAVED edit on line 1 of w.txt press left 10 8 release left 10 8 stable 400 5000 key i text MYEDIT key esc settle 100 stable 400 5000 snap edited # ---- from here to `snap reloaded_sub`, pardes is sent NOTHING ---- # w.txt has the unsaved edit: it is kept, and the change is said run printf 'EXTERNAL\n' > w.txt wait 10000 changed on disk stable 700 10000 snap kept # sub/s.txt has none: it takes the new text run printf 'RENAMED\n' > sub/t && mv sub/t sub/s.txt wait 10000 RENAMED stable 700 10000 snap reloaded_sub