Is the file saved or not? Why is there still an asterix on the tab?

Hello,

When I use search and replace functions (Edit > Find > Replace in Path) and replace fragments in multiple files, the files are not required to be open. Eg, I can specify a directory and its sub-directories and the replace function will replace everything in the files within the selected directories.

However, I noticed when I open one of those files, the content actually is showing correctly (eg, the fragment was replaced) but on the editor tab, the asterix is showing - meaning the file is modified but is not saved.

This is really confusing. What does this mean? Is the file modifed and not saved? But then why is it showing the correct content? If the content is correct why is there an asterix on the tab when the file is opened?

What will happen if I do a commit to a repo? Will the new content be commited? Or the old one?

Thanks.

6 comments
Comment actions Permalink

Hi there,

Is the file modifed and not saved? But then why is it showing the correct content? If the content is correct why is there an asterix on the tab when the file is opened?

Content is modified, but no actual changes were made to the files yet (it's all in memory -- don't know more appropriate term). Just click on "Save" and it will flush/apply all modifications to the actual files on disk.

Such behaviour very handy (and possibly implemented for such situations) for Undo such batch operations (Replace in multiple files) -- much easier than tracing each modified file and undoing them one by one). Plus it helps to prevent externally running tools (e.g. file watchers -- automatic compilling of less/scss and similar) and some internal functionality (e.g. automatic upload of modified files to FTP/SFTP/etc) from premature execution when some files opened in editor are still not saved but others are already uploaded/compiled (which can easily lead to not-working code).

What will happen if I do a commit to a repo? Will the new content be commited? Or the old one?

New one -- IDE will perform implicit "Save" for you at some point before the actual commit.

0
Comment actions Permalink

Ok. Thanks for the clarification!

0
Comment actions Permalink

So let's assume, I have a project open and have a few windows open with edited files. I close them. Since I did not save them, they are modified in memory.

Now, I want to open a text file which is totally unrelated to the project I am working on. Let's say someone sent me a text file and I want to edit it. Or, since I can use PS as a text editor, I create a new file and start typing my favorite recipe so I can send it to someone. Again, this activity is not project related. Just a simple text file. Why bother opening yet another text editor just for this task when I can use PH, no?

So then I save this text file. Now, since I selected "Save" not only my text file - which is unrelated to the project - but every single project file will be saved.

So I can see your point, and what you mentioned about undoing a search/replace in multiple files at once is convenient, in the above mentioned case it's not.

Would be nice to have an option where I could specify how treat "Save". Whether it's for the current file only, or for the whole project.

0
Comment actions Permalink

First of all -- PhpStorm is not just advanced text editor with syntax highlighting -- it is whole IDE and it works differently (in some aspects) to other products. Therefore I think (my personal opinion) it's your own problem that you edit completely unrelated files in IDE. Right now you know how it works and I'm pretty sure you will not do this (your hypothetical example) in real life :).

Secondly -- when you create new file, the file will be physically created straight away (not like in Notepad++ or whatever) -- when new editor tab is opened, there is real file behind it.

When it saves -- it saves all changes at once. It's one of the key elements of the IDEA platform which is not planned to be changed in foreseeable future (that's the answer I saw pretty much all the time for such questions). Check for details: http://devnet.jetbrains.net/docs/DOC-191

0
Comment actions Permalink

it's your own problem that you edit completely unrelated files in IDE

You are right about that!

...and I'm pretty sure you will not do this (your hypothetical example) in real life :).

Actually, I ran into this a few times already. I switched from DreamWeaver to PhpStorm not long ago. I manage an institution's website. 15,530 files in 2,700 total folders. I have 3 servers: development, testing, production. They are all remote servers on a network. The servers are running IIS and .NET and the pages are aspx, but none of them has .NET functionality in it so I can manage them with PhpStorm just fine.

Anyhow. The dev server has it's own web.config file which is different from the one on the testing and live servers. I had files open and realized I want to edit the web.config file but only on the testing server.

So I have to manually navigate (using windows explorer) to the testing server, and open the web.config file. And this is where it got me. I have to open the config file in another editor because if I save it, all the other non-saved files on the dev server will be saved  - which I not necessarily want.

But I could have the same example with htaccess files, where the dev server could have different content in it as on the testing and live servers. In these cases I need to edit the file(s) in another editor - provided I don't want to save all already open files along with it.

0
Comment actions Permalink

Occasionally, once a year I come back to check if phpstorm made up their mind and implemented the normal Save funcionality. Everytime I quit with disappointment. I see their IDEA (not a good idea) 'platform' won't be changing anytime soon. There's a galaxy of similar use-cases and confusions when this IDE could break your application, sometimes job etc. That's why me and my colleagues will never ever consider this program as long as it doesn't adopt the world's most adequate way of editing a file, applciation, projects content.
When you have all world's companies producing round tires for cars, and one is producing square tires, there's definitely something wrong. It ain't round tires. Jetbrains is trying to convince you that their new and "improved" suspension system can deal with square tires.

0

Please sign in to leave a comment.