mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +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) {
|
protected void handleActivated(Editor whichEditor) {
|
||||||
activeEditor = whichEditor;
|
activeEditor = whichEditor;
|
||||||
activeEditor.rebuildRecentSketchesMenu();
|
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
|
// set the current window to be the console that's getting output
|
||||||
EditorConsoleStream.setCurrent(activeEditor.console);
|
EditorConsoleStream.setCurrent(activeEditor.console);
|
||||||
|
@ -108,6 +108,10 @@ public class Sketch {
|
|||||||
* in which case the load happens each time "run" is hit.
|
* in which case the load happens each time "run" is hit.
|
||||||
*/
|
*/
|
||||||
protected void load() throws IOException {
|
protected void load() throws IOException {
|
||||||
|
load(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void load(boolean forceUpdate) throws IOException {
|
||||||
data.load();
|
data.load();
|
||||||
|
|
||||||
for (SketchCode code : data.getCodes()) {
|
for (SketchCode code : data.getCodes()) {
|
||||||
@ -117,7 +121,7 @@ public class Sketch {
|
|||||||
|
|
||||||
// set the main file to be the current tab
|
// set the main file to be the current tab
|
||||||
if (editor != null) {
|
if (editor != null) {
|
||||||
setCurrentCode(0);
|
setCurrentCode(currentIndex, forceUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -979,8 +983,12 @@ public class Sketch {
|
|||||||
* </OL>
|
* </OL>
|
||||||
*/
|
*/
|
||||||
public void setCurrentCode(int which) {
|
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 current is null, then this is the first setCurrent(0)
|
||||||
if ((currentIndex == which) && (current != null)) {
|
if (!forceUpdate && (currentIndex == which) && (current != null)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1065,11 +1073,8 @@ public class Sketch {
|
|||||||
//handleOpen(sketch);
|
//handleOpen(sketch);
|
||||||
//history.lastRecorded = historySaved;
|
//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
|
// nuke previous files and settings, just get things loaded
|
||||||
load();
|
load(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // handle preprocessing the main file's code
|
// // handle preprocessing the main file's code
|
||||||
|
Loading…
Reference in New Issue
Block a user