tldr: when it’s running, PyCharm does automatic change detection and file history for files in the project directory (at least text files with known file types, e.g., ‘yaml’, ‘txt’, ‘py’, etc., including those edited with other apps) = seamless local backups of config files.
My apologies if I’m the last person to figure this out – did a quick search and didn’t see mention of my particular experience, so I’ll share:
I’m a huge fan of PyCharm, and have been using it at work and personally for several years. Two minor things have always annoyed me though…first, it tends to create HUGE “app_data” directories, and second, I never have the patience when restarting the IDE and it’s doing all its normal business…indexing, updating, etc. (which turns out out to be crucial in my case).
But yesterday it saved my life (metaphorically speaking, of course).
So the “bug” from my title is a very odd behavior that often happens with configurator
: when reloading (in Firefox), it will strangely give me just a line or two snippet of the yaml
I was working last on, and I have to carefully reload the file to avoid overwriting it.
Yesterday, in the process of reloading ui-lovelace.yaml
, my nightmare scenario happened and basically the whole file was overwritten with an empty file. I researched options for recovery, didn’t find much help – although I hadn’t actively backed up my
config
files I have some older copies laying around, so I began the heartbreaking process of rebuilding from an outdated version.
And now we come to the point of the post: on a whim, since I do code my HA python scripts in PyCharm (using the config
folder as the project directory), I loaded ui-lovelace.yaml
in the editor and then pulled up the file history and yes PyCharm had tracked all changes for the last two months! So apparently it does change-detection on files with recognized file types in the project folder, including files that are “externally edited.” I was astonished as (1) it never occurred to me to use PyCharm to edit yaml’s (which of course it does natively, the same way it handles multiple other file formats), and (2) I had never opened any yaml files inside the IDE, so didn’t expect PyCharm to have a history of their contents.
What a relief it was to cut-and-paste the latest content back in to ui-lovelace.yaml
and get back to work on my layout! And now, when I restart PyCharm and see the progress bar indexing and chugging along, I’ll take a few deep breaths and celebrate my good fortune.
-Matt