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:
parent
c08fd76cad
commit
6558c0654e
@ -91,7 +91,6 @@ public class AStyle implements Tool {
|
|||||||
int line = getLineOfOffset(textArea);
|
int line = getLineOfOffset(textArea);
|
||||||
int lineOffset = getLineOffset(textArea, line);
|
int lineOffset = getLineOffset(textArea, line);
|
||||||
|
|
||||||
editor.removeAllLineHighlights();
|
|
||||||
editor.getCurrentTab().setText(formattedText);
|
editor.getCurrentTab().setText(formattedText);
|
||||||
|
|
||||||
if (line != -1 && lineOffset != -1) {
|
if (line != -1 && lineOffset != -1) {
|
||||||
|
@ -383,6 +383,9 @@ public class EditorTab extends JPanel implements SketchCode.TextStorage {
|
|||||||
* Replace the entire contents of this tab.
|
* Replace the entire contents of this tab.
|
||||||
*/
|
*/
|
||||||
public void setText(String what) {
|
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
|
// Set the caret update policy to NEVER_UPDATE while completely replacing
|
||||||
// the current text. Normally, the caret tracks inserts and deletions, but
|
// 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,
|
// replacing the entire text will always make the caret end up at the end,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user