Open
Description
I frequently edit my code in both the IDE and external to the IDE when I program in xCode (not necessary to ask why--trust me--it makes sense).
In xCode, this works fine because the file reloads (assuming it's been saved in the IDE--it warns me otherwise), if I edit it externally.
In Arduino IDE the file does not reload (either automatically or after a warning). In other words, the Arduino IDE is ignoring OS X's message that the file has changed.
Suggestion: IDE should watch for and react to externally edited files and update the file in the IDE if it changes. This is, what I would call, "standard operating procedure."
Activity
lmihalkovic commentedon Feb 9, 2016
Aside from the 'simple' possibility of a manual chk upon window activation, there is a standard java API for doing that cross platform.
tjayrush commentedon Feb 9, 2016
Sorry for the newbie question (new to GitHub and Arduino). Does your comment mean "Cool idea, go ahead and implement that in your [me] own version," or "Good idea. I [Arduino developers] will make that change"?
As I say, I'm new to this whole thing. Thanks.
chrstphrchvz commentedon Feb 9, 2016
(Another user here.) Note that in Preferences there is the "Use external editor" option that causes the editor to be read-only, and does refresh project to refresh upon focusing on the Arduino IDE--but this is not an option if you still need to use the Arduino IDE's editor. I agree that this is somewhat non-standard where other editors such as XCode, TextWrangler watch for file changes rather than application focus, and allowing out-of-the-box compatibility with git.
lmihalkovic commentedon Feb 10, 2016
@tjayrush there may not be a straight answer ... i would not dare presume what the Arduino team will do. However you may want to read all the other open issues and reach your own conclusions about what they are likely/unlikely to implement. Speaking in my own name, i find the idea interesting and there is a chance i will do something about it in a different setting
VioletGiraffe commentedon Feb 24, 2017
I want to bump this issue. Detecting file changes and prompting to reload modified files is basic functionality in any IDE or even a plain text editor. Even if you don't do any fancy stuff like working on the same project in two different IDEs at the same time (which I do), you will still come across this problem as soon as you put your project under version control. You revert some changes or switch to another revision - boom, you have stale code in your IDE, possibly without noticing a problem for some time.
facchinm commentedon Feb 24, 2017
Unless you select "Use external editor", the IDE keeps the sketch is a memory buffer and saves it to a temporary file when needed.
This allows compiling (and testing) a sketch without necessarily overwriting the original one (I doubt any other IDE does that, but it's very common to open Blink, change the pin and upload the code without saving anything). But since it's not disk-backed, this flow doesn't allow the sketch to reload a file while running as editor.
If someone has a proposal that preserves the current behaviour while allowing a sketch to be reloaded I'll be glad to analyse and implement it.
VioletGiraffe commentedon Feb 24, 2017
@facchinm
I see what you mean, however it doesn't seem to be much different from any other IDE. You open files and edit them all the time so the files are in an unsaved state. It is not uncommon then to change the file externally, and when you go back to the IDE you get a prompt:
I don't see why the exact same behavior won't work with Arduino - without changing anything else.
facchinm commentedon Feb 24, 2017
The difference is that if you don't save a file in a normal IDE you compile the on-disk file, not the temporary copy. So for a normal IDE the "reload" dialog is a must, while in our case it would be somehow counter-intuitive. I'm not saying we are not going to implement somethig similar sooner or later but I'd give a low priority to this task
VioletGiraffe commentedon Feb 24, 2017
@facchinm : in my opinion that changes nothing and poses no problems. Say you've opened some example, then edited and uploaded it. How probable do you think it is that the example file you started with will be modified? I think that's unlikely. In any of the cases where Arduino IDE's in-memory compilation feature is useful, I don't think a prompt I'm asking about would ever appear at all. It would appear in the cases where it's actually required (e. g. you're working with your sketch in a version control repository).
facchinm commentedon Feb 24, 2017
That makes sense, indeed, I'm only saying it's not top priority, and neither it's an easy check between (local) file timestamps
lmihalkovic commentedon Feb 24, 2017
This has been standard behavior in IDEs for years now.. the arduino environment persists in redifining what is standard expectation.. if you convince yourselves it is great.. but don t expect that it might always work with everyone
VioletGiraffe commentedon Feb 24, 2017
@facchinm: I would do it with a file system watcher which is the OS-level tool just for this task, rather than rely on timestamps.
lmihalkovic commentedon Feb 24, 2017
Not wanting to deal with the technical problems is one thing (we already know we are in different places on the continuum of what is 'difficulty'), but wanting to convince people they don t need what they wish for or .. is a very different type of response
lmihalkovic commentedon Feb 24, 2017
.. in my very humble opinion.
matthijskooijman commentedon Feb 24, 2017
I'd also like to see some prompt to reload on change, seems like a worthwhile addition to me (and has been on my mental TODO-list for a while, though I'll probably never find time for it). In my workflow I often use an external editor, but sometimes I quickly load a sketch and want to make some changes to it in the Arduino IDE. Now I end up toggling the external editor option every now and then, but that's not ideal. I also don't think that this would conflict with how the editor handles files currently.
Wrt implementation, the screenshots seem like good examples. I'd imagine something like:
57 remaining items
Add watcher on sketch files
Add watcher on sketch files
Add watcher on sketch files
Add watcher on sketch files
Add watcher on sketch files
Add watcher on sketch files
Add watcher on sketch files
Add watcher on sketch files
Add watcher on sketch files