From 20ed5a209c7e37be76356a1c2004f166d76f4f0c Mon Sep 17 00:00:00 2001 From: Maged Ahmed Rifaat Date: Sun, 22 Dec 2019 18:31:39 +0200 Subject: [PATCH] Fix wrong bracket match rectangle on auto format This commit fixes instances when setText is called on editorTab and the rectangle that highlights the bracket match becomes incorrect. This is because text is inserted to the document without notifying the textarea. Calling setLineWrap internally fires an event that recalculates the bracket match rectangle and thus solves the problem. --- app/src/processing/app/EditorTab.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/processing/app/EditorTab.java b/app/src/processing/app/EditorTab.java index 416a99836a5..5e8f3e4bfcf 100644 --- a/app/src/processing/app/EditorTab.java +++ b/app/src/processing/app/EditorTab.java @@ -442,6 +442,9 @@ public void setText(String what) { } finally { caret.setUpdatePolicy(policy); } + // A trick to force textarea to recalculate the bracket matching rectangle. + // In the worst case scenario, this should be ineffective. + textarea.setLineWrap(textarea.getLineWrap()); } /**