Skip to content

Commit 6558c06

Browse files
matthijskooijmanfacchinm
authored andcommitted
Remove all highlights in EditorTab.setText()
When completely replacing all text, all highlights will end up at the start of the file. Since keeping them at the right place is tricky (even impossible in some circumstances), just remove them now. This already happened in the autoformat code, so that part can be removed.
1 parent c08fd76 commit 6558c06

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

app/src/cc/arduino/packages/formatter/AStyle.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public void run() {
9191
int line = getLineOfOffset(textArea);
9292
int lineOffset = getLineOffset(textArea, line);
9393

94-
editor.removeAllLineHighlights();
9594
editor.getCurrentTab().setText(formattedText);
9695

9796
if (line != -1 && lineOffset != -1) {

app/src/processing/app/EditorTab.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ public String getText() {
383383
* Replace the entire contents of this tab.
384384
*/
385385
public void setText(String what) {
386+
// Remove all highlights, since these will all end up at the start of the
387+
// text otherwise. Preserving them is tricky, so better just remove them.
388+
textarea.removeAllLineHighlights();
386389
// Set the caret update policy to NEVER_UPDATE while completely replacing
387390
// the current text. Normally, the caret tracks inserts and deletions, but
388391
// replacing the entire text will always make the caret end up at the end,

0 commit comments

Comments
 (0)