🟢 [L6] load_file 失败后 watcher 已清空但旧状态残留 #32
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
文件:
tui/app.rs:144-190分类: 状态一致性
问题:
load_file先清空 watcher,如果打开失败,旧loading_state和file_path残留,watcher 已丢失。建议修复: 先暂存新状态,成功后原子替换;失败时完整保留旧状态或转 Error 状态。
已修复 — commit 967c11f
根因:
load_file在第154行先清空file_watcher,如果后续ProgressiveFileReader::open失败,?提前返回导致 watcher 丢失,而loading_state和file_path仍残留旧值。修复方式:重构为 build-then-swap 模式:
测试:
test_file_watcher_preserved_on_nonexistent_file验证失败后 watcher、file_path、loading_state 均保留。全量 129 tests 通过。