Commit graph

8 commits

Author SHA1 Message Date
Ed Sanders f0fb93d3e1 ESLint: Enforce prefer-const
Change-Id: I7f45137a47dddcd2fc70201f28680edce907b522
2024-06-22 10:26:58 +01:00
Ed Sanders 1b101f09ee ESLint: Update syntax to ES6 and autofix
Change-Id: I613cc64a9bf3f375a40f75a1441b83f181a2ab42
2024-06-22 10:26:58 +01:00
Thiemo Kreuz 20debba3b0 Enable eslint for our custom code in the matchbrackets addon
The resulting code style in this file is a little mixed. I tried to
stick to the existing style. Most notably is the indention with
2 spaces instead of 1 tab. But I couldn't disable the spaces inside
round brackets. They make the code so much more readable.

What this patch effectively does is enabling the eslint check for our
custom code in this addon, excluding all old code, and exclusing a few
rules that conflict to heavily with the old code style.

Change-Id: I12f953cb0a6fd35e405b6cc348abfb2c11e70696
2022-03-03 21:07:19 +00:00
Thiemo Kreuz 5186c6f3a2 Fix bracket matching getting stuck when leaving the brackets
Bug: T278840
Bug: T280978
Change-Id: Ia552fcd829ce38cbb7ac7fd7ebecad971a83e4c3
2021-04-23 14:48:23 +02:00
Thiemo Kreuz 6937d0e51c Fix incomplete (auto)clear for highlighted brackets
The issue can be reproduced as described in T278840. What
happens is that an (auto)clear is triggered and removes all
marks, but the cached values in `currentMarks` remain. The next
time the same marks are found, they are discarded and don't
show up, because the cache says they are already there, when
they are not.

Bug: T278840
Change-Id: If83bd99e924f579854cfe4b01fab4ef86892933b
2021-04-09 11:07:26 +02:00
WMDE-Fisch 9bea2a7905 Refine bracket matching styling
Adds a custom class for matched brackets to allow better integration
with custom bracket styles. The brackets won't be bold in the 2017WTE.
Bold font might lead to misalignment there. See ticket.

Note: box-shadow seems to be supported for quite some time by all
relevant browsers

Bug: T270926
Change-Id: Ica1e301f63a106a96db3bfaba4b2f322af64b009
2021-03-08 09:26:07 +01:00
Thiemo Kreuz 6bc81ffd50 Improve matchbrackets performance when moving the cursor
My previous patch Icbb1122 focused on the behavior of the
matchbrackets addon when the text is *edited*. This patch here
is about moving the cursor without changing the text. I
realized the addon re-draws everything every time the cursor
moves, even if the highlighted pair of brackets is still the
same. This triggers very expensive code in the CodeMirror lib.

I had a look at this expensive code, but did not found an easy
win. It just is what it is: an expensive re-draw. Instead I
introduced a caching layer that remembers the positions of the
previously highlighted brackets and bails out as early as
possible when nothing changed.

The biggest chunk of code is that "did something change?"
comparison. It looks expensive, but typically isn't. There are
typically only 2 elements in the array for a single
opening–closing pair. (Possibly more when there are multiple
text selections.) The elements in the two arrays are typically
in the same order. (Except the cursor is on the closing
bracket.) Which means the nested `every` → `for` loop will
typically be executed 2 times only – one time for each of the
2 elements.

I won't upload this change upstream because it is only relevant
together with our custom "in the middle" bracket highlighting.
With our customization we have many, many situations where the
highlighted brackets don't change. This (almost) doesn't happen
upstream.

Bug: T270317
Change-Id: I789b45362388f0818e797f789f6af427a35e3e06
2021-01-27 08:54:32 +00:00
Thiemo Kreuz 473a711aaa Rename our customized matchbrackets addon
Bug: T269096
Change-Id: I5b58099166f71ccc1b3b19334f28e8bbaafaceb3
2021-01-20 11:17:59 +01:00