1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-19 08:52:15 +01:00

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.
This commit is contained in:
Matthijs Kooijman 2015-12-09 12:21:56 +01:00 committed by Martino Facchin
parent c08fd76cad
commit 6558c0654e
2 changed files with 3 additions and 1 deletions

View File

@ -91,7 +91,6 @@ public class AStyle implements Tool {
int line = getLineOfOffset(textArea);
int lineOffset = getLineOffset(textArea, line);
editor.removeAllLineHighlights();
editor.getCurrentTab().setText(formattedText);
if (line != -1 && lineOffset != -1) {

View File

@ -383,6 +383,9 @@ public class EditorTab extends JPanel implements SketchCode.TextStorage {
* Replace the entire contents of this tab.
*/
public void setText(String what) {
// Remove all highlights, since these will all end up at the start of the
// text otherwise. Preserving them is tricky, so better just remove them.
textarea.removeAllLineHighlights();
// Set the caret update policy to NEVER_UPDATE while completely replacing
// the current text. Normally, the caret tracks inserts and deletions, but
// replacing the entire text will always make the caret end up at the end,