refactor(cmd/gf): Optimize run command to reload only on actual file changes#4476
Merged
hailaz merged 2 commits intogogf:masterfrom Oct 16, 2025
Merged
refactor(cmd/gf): Optimize run command to reload only on actual file changes#4476hailaz merged 2 commits intogogf:masterfrom
hailaz merged 2 commits intogogf:masterfrom
Conversation
gf run 的文件监控逻辑之前会对所有文件系统事件做出响应,包括非内容修改的事件(如文件access time变化),这会导致开发过程中不必要的频繁重载。本次修改在文件监控回调中增加了event.IsWrite()的判断,确保只有在文件内容被实际写入时才触发重载逻辑,优化了开发体验。
Contributor
|
@windvalley |
hailaz
approved these changes
Oct 16, 2025
除了忽略掉非Write, 也忽略掉非Create、Remove、Rename的事件组合,确保了只有在代码内容或结构发生实质性变化时才触发重载。
Contributor
Author
@hailaz 我在使用warp终端时,当项目仓库中git暂存区有内容时,就会反复触发chmod事件的reload,直到暂存区内容被清空或提交后,才不会reload。考虑到chmod事件并不会对代码产生实质变化没必要reload,所以可以忽略掉。已经更新代码,把您说的其他对代码有实质影响的event场景也考虑进去了:) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
优化run命令使得只在文件有写入事件时才触发reload:
gf run 的文件监控逻辑之前会对所有文件系统事件做出响应,包括非内容修改的事件(如文件access time变化),这会导致开发过程中不必要的频繁重载。本次修改在文件监控回调中增加了event.IsWrite()的判断,确保只有在文件内容被实际写入时才触发重载逻辑,优化了开发体验。