简体   繁体   English

如何在PhpStorm中检测到更改时刷新文件

[英]How to refresh file when changes are detected in PhpStorm

My colleague and I are working on the same project in PhpStorm shared in network, and it happens that we are editing the same Javascript file, however when I change the file, there is a delay for the update file on his computer and it's the same with me. 我和我的同事正在网络中共享PhpStorm中的同一个项目,而且我们正在编辑相同的Javascript文件,但是当我更改文件时,他的计算机上的更新文件有延迟而且它是相同的与我一起。 Is there a way to make the PhpStorm update the file when it detects a change? 有没有办法让PhpStorm在检测到更改时更新文件? Without this delay? 没有这个延迟?

Go to File>Synchronize to refresh the files in the project or Use the shortcut Ctrl + Alt + Y in windows and Cmd + Alt + Y in Mac. 转到文件>同步以刷新项目中的文件或使用Windows中的快捷键Ctrl + Alt + Y和Mac中的Cmd + Alt + Y.

在此输入图像描述

Responsible for the delay you encounter is not PhpStorm but the network. 负责您遇到的延迟不是PhpStorm而是网络。 Even on local networks, it takes some time (seconds) for changes to propagate to other computers. 即使在本地网络上,更改传播到其他计算机也需要一些时间(秒)。 The reason in not in hardware but in the way the network sharing is implemented in software. 原因不在于硬件,而在于网络共享在软件中实现的方式。

The programs can subscribe to get notified by the OS about events on a specified file or directory. 程序可以订阅以获得操作系统关于指定文件或目录上的事件的通知。 When an event happens, the programs on the local computer that subscribed are notified almost instantly. 当事件发生时,几乎立即通知订阅的本地计算机上的程序。 This is not possible when the files are on another computer; 当文件在另一台计算机上时,这是不可能的; the changes on the remote drive are visible to local programs when the network sharing software on the two computers exchange information about what happened sync their last communication. 当两台计算机上的网络共享软件交换有关同步其上次通信的信息时,本地程序可以看到远程驱动器上的更改。

Because network communication takes time and resources, the sharing programs usually publish their information in batches. 由于网络通信需要时间和资源,因此共享程序通常会批量发布其信息。 If a file changes it waits some time (let's say half of second), maybe some other change happens and it can publish both in a single batch. 如果文件发生了变化,它会等待一段时间(让我们说一半的时间),也许会发生其他一些变化,它可以在一个批次中发布。 If nothing happens then it decides it's the time to inform the other computers in the network about the changes. 如果没有任何反应,则决定是时候通知网络中的其他计算机有关更改的信息。

It's also possible that PhpStorm queries the file status from time to time. PhpStorm也可能不时查询文件状态。 Again, because of network overload it cannot do it continuously; 同样,由于网络过载,它无法连续进行; it would be a waste of processing time and resources. 这将浪费处理时间和资源。

I think using your current setup this is the best you can get. 我认为使用您当前的设置这是您可以获得的最佳效果。

You could manually reload file changes by clicking File > Synchronize , if it's not reloading automatically. 如果没有自动重新加载,您可以通过单击File > Synchronize手动重新加载文件更改。

And for automatic reload go to File > Settings > Appearance & Behavior > System Settings and under Synchronization section check Synchronize files on frame or editor tab activation and save this settings by pressing OK . 对于自动重新加载,请转到File > Settings > Appearance & Behavior > System Settings然后在Synchronization部分下,选中框架或编辑器选项卡激活时同步文件,然后按OK保存此设置。 That's it. 而已。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM