Skip to content

Commit 9518aa4

Browse files
committed
Ensure line is unfolded when highlighting for error
Fixes #8457 For some reason, getCurrentTab().getTextArea().getFoldManager().ensureOffsetNotInClosedFold(line) doesn't work here; there no documentation on what offset is. Also, getFoldForLine(line) returns null even if the line is folded (bug in rsyntaxtextarea?)
1 parent a5e866f commit 9518aa4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/src/processing/app/Editor.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
import javax.swing.event.MenuListener;
8383
import javax.swing.text.BadLocationException;
8484

85+
import org.fife.ui.rsyntaxtextarea.folding.FoldManager;
86+
8587
import com.jcraft.jsch.JSchException;
8688

8789
import cc.arduino.CompilerProgressListener;
@@ -1648,8 +1650,17 @@ public void removeAllLineHighlights() {
16481650
}
16491651

16501652
public void addLineHighlight(int line) throws BadLocationException {
1651-
getCurrentTab().getTextArea().addLineHighlight(line, new Color(1, 0, 0, 0.2f));
1652-
getCurrentTab().getTextArea().setCaretPosition(getCurrentTab().getTextArea().getLineStartOffset(line));
1653+
SketchTextArea textArea = getCurrentTab().getTextArea();
1654+
FoldManager foldManager = textArea.getFoldManager();
1655+
if (foldManager.isLineHidden(line)) {
1656+
for (int i = 0; i < foldManager.getFoldCount(); i++) {
1657+
if (foldManager.getFold(i).containsLine(line)) {
1658+
foldManager.getFold(i).setCollapsed(false);
1659+
}
1660+
}
1661+
}
1662+
textArea.addLineHighlight(line, new Color(1, 0, 0, 0.2f));
1663+
textArea.setCaretPosition(textArea.getLineStartOffset(line));
16531664
}
16541665

16551666

0 commit comments

Comments
 (0)