Go to file
Thiemo Kreuz 7fada45067 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 10:32:57 +00:00
.phan Add phan 2019-04-09 20:35:56 +02:00
i18n Localisation updates from https://translatewiki.net. 2020-12-28 10:37:43 +01:00
includes Provide cookie workaround for setting the feature flag 2021-01-04 16:09:11 +01:00
resources Improve matchbrackets performance when moving the cursor 2021-01-27 10:32:57 +00:00
tests Browser tests for CodeMirror (wikitext 2017 editor) 2021-01-11 12:47:49 +01:00
.eslintrc.json build: Update devDependencies 2020-06-12 22:51:38 +01:00
.gitignore Browser tests for CodeMirror (wikitext 2010 editor) 2021-01-08 11:01:13 +01:00
.gitreview Whoops, track not trace 2016-10-24 17:02:17 -07:00
.phpcs.xml Remove @staticvar doc annotation 2018-09-09 20:04:35 +02:00
.stylelintrc.json Update CodeMirror to 5.58.3 2020-12-07 20:20:49 +00:00
CODE_OF_CONDUCT.md build: Updating mediawiki/phan-taint-check-plugin to 1.3.0 2018-08-19 10:46:12 +00:00
composer.json build: Updating ini to 1.3.8 2021-01-14 15:20:11 +00:00
COPYING CodeMirror: Add COPYING file and credit for CodeMirror authors 2020-03-02 21:34:06 +00:00
extension.json Added bracket matching 2020-12-15 13:09:06 +00:00
Gruntfile.js Added bracket matching 2020-12-15 13:09:06 +00:00
package-lock.json build: Updating ini to 1.3.8 2021-01-14 15:20:11 +00:00
package.json Browser tests for CodeMirror (wikitext 2010 editor) 2021-01-08 11:01:13 +01:00