19

当一个文件被phpstorm打开时,我做了一些更改而不保存。但与此同时,磁盘上的文件也发生了变化。然后 phpstorm 将从磁盘重新加载文件,没有提示。我的所有更改都将丢失。

4

2 回答 2

33
  1. Settings/Preferences | Appearance & Behavior | System Settings

  2. 取消Synchronize files on frame activation勾选选项

现在 PhpStorm 会问你该怎么做:你将有几个选项可供选择:

  • 加载文件系统更改(从文件加载外部更改)
  • 保留内存更改(忽略外部更改并继续编辑器中的文本)
  • 显示差异(显示差异视图以查看差异并决定需要手动更改的内容)
于 2011-07-08T18:17:33.987 回答
3

@LazyOne 的答案与 PhpStorm 的早期版本有关。在 PhpStorm 8.0 中,有两个复选框可以更精细地控制文件同步设置:

  1. 在 PhpStorm 中,通过从菜单中选择Preferences或单击 ⌘ Comma (Mac) 或 Ctrl+Alt+S(Linux 和 Windows)打开 Settings / Preferences 对话框。
  2. 单击外观和行为,然后单击系统设置
  3. Synchronization下,有两个复选框:第一个标记为Synchronize files on frame activation,第二个标记为Save files on frame deactivation

以下是复选框的作用:

  • Checking the first box will detect and reload external files from the disk when you switch to PhpStorm from another application.
  • Checking the second box will have all modified files saved every time you switch to another application from PhpStorm.
  • If you uncheck both boxes, PhpStorm provids a simple prompt says "File was changed on disk" with a link to reload them in PhpStorm.

When there is conflict between PhpStorm and the file that changes on the disk, you will be asked to choose what to do:

  • Load Changes: Click this button to load the file version produced outside of PhpStorm, and overwrite your local changes.
  • Keep Memory Changes: Click this button to preserve the version produced in PhpStorm and stored in cache.
  • Show Difference Click this button to invoke the differences viewer that shows the version in the file system to the left, and PhpStorm version to the right.

More details can be found in the PhpStorm documentation pages for System Settings and the File Cache Conflict pages.

于 2015-03-17T18:40:22.937 回答