mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
Update sketch code when editing with an external editor and IDE gets focus. Fixes #1778
This commit is contained in:
parent
aef835b45c
commit
22e9d25245
@ -623,6 +623,13 @@ public class Base {
|
||||
protected void handleActivated(Editor whichEditor) {
|
||||
activeEditor = whichEditor;
|
||||
activeEditor.rebuildRecentSketchesMenu();
|
||||
if (PreferencesData.getBoolean("editor.external")) {
|
||||
try {
|
||||
activeEditor.getSketch().load(true);
|
||||
} catch (IOException e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
// set the current window to be the console that's getting output
|
||||
EditorConsoleStream.setCurrent(activeEditor.console);
|
||||
|
@ -108,6 +108,10 @@ public class Sketch {
|
||||
* in which case the load happens each time "run" is hit.
|
||||
*/
|
||||
protected void load() throws IOException {
|
||||
load(false);
|
||||
}
|
||||
|
||||
protected void load(boolean forceUpdate) throws IOException {
|
||||
data.load();
|
||||
|
||||
for (SketchCode code : data.getCodes()) {
|
||||
@ -117,7 +121,7 @@ public class Sketch {
|
||||
|
||||
// set the main file to be the current tab
|
||||
if (editor != null) {
|
||||
setCurrentCode(0);
|
||||
setCurrentCode(currentIndex, forceUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -979,8 +983,12 @@ public class Sketch {
|
||||
* </OL>
|
||||
*/
|
||||
public void setCurrentCode(int which) {
|
||||
setCurrentCode(which, false);
|
||||
}
|
||||
|
||||
public void setCurrentCode(int which, boolean forceUpdate) {
|
||||
// if current is null, then this is the first setCurrent(0)
|
||||
if ((currentIndex == which) && (current != null)) {
|
||||
if (!forceUpdate && (currentIndex == which) && (current != null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1065,11 +1073,8 @@ public class Sketch {
|
||||
//handleOpen(sketch);
|
||||
//history.lastRecorded = historySaved;
|
||||
|
||||
// set current to null so that the tab gets updated
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=515
|
||||
current = null;
|
||||
// nuke previous files and settings, just get things loaded
|
||||
load();
|
||||
load(true);
|
||||
}
|
||||
|
||||
// // handle preprocessing the main file's code
|
||||
|
Loading…
Reference in New Issue
Block a user