When a file is open by phpstorm, and I make some changes without save. But at the same time, the file on disk is changed. Then phpstorm will reload the file from disk, without prompt. All my changes will lost.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Settings/Preferences | Appearance & Behavior | System Settings
Untick
Synchronize files on frame activation
option
Now PhpStorm will ask you what to do: you will have few options to choose from:
- Load File System Changes (load external changes from file)
- Keep Memory Changes (ignore external changes and continue with text in editor)
- Show Difference (show difference view to see the difference and decide what needs to be changed manually)
回答2:
@LazyOne's answer pertains to an earlier version of PhpStorm. In PhpStorm 8.0 there are two checkboxes to provide more granular control over your file synchronization settings:
- In PhpStorm, open the Settings / Preferences Dialog by choosing Preferences from the menu or clicking ⌘ Comma (Mac) or Ctrl+Alt+S (Linux and Windows).
- Click Appearance & Behavior, then click System Settings.
- Under Synchronization, there are two checkboxes: the first is labelled Synchronize files on frame activation and the second is labelled Save files on frame deactivation
Here is what the checkboxes do:
- 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.