Skip to content

Commit 5427f94

Browse files
committed
Do not allow negative font resize
Fix arduino#6359 (again)
1 parent fcd88e6 commit 5427f94

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

app/src/processing/app/Base.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -1854,11 +1854,18 @@ public void handlePrefs() {
18541854
* Adjust font size
18551855
*/
18561856
public void handleFontSizeChange(int change) {
1857-
String pieces[] = PApplet.split(PreferencesData.get("editor.font"), ',');
1858-
int newSize = Integer.parseInt(pieces[2]) + change;
1859-
pieces[2] = String.valueOf(newSize);
1860-
PreferencesData.set("editor.font", PApplet.join(pieces, ','));
1861-
this.getEditors().forEach(processing.app.Editor::applyPreferences);
1857+
String pieces[] = PreferencesData.get("editor.font").split(",");
1858+
try {
1859+
int newSize = Integer.parseInt(pieces[2]) + change;
1860+
if (newSize < 4)
1861+
newSize = 4;
1862+
pieces[2] = String.valueOf(newSize);
1863+
} catch (NumberFormatException e) {
1864+
// ignore
1865+
return;
1866+
}
1867+
PreferencesData.set("editor.font", StringUtils.join(pieces, ','));
1868+
getEditors().forEach(Editor::applyPreferences);
18621869
}
18631870

18641871
// XXX: Remove this method and make librariesIndexer non-static

0 commit comments

Comments
 (0)