User blog comment:Kirkburn/Syntax highlighting - helping you read and write code/@comment-1038387-20150326195108/@comment-452-20150326211413

The word "lag" implies a "noticeable and unwelcome delay", but a "when a user types the opening characters of a highlightable section, assume the sentence the user is currently typing is going to close the same section, until they press mouse-button/u/d/r/pgdn/pgup/end/home/tab and then update the highlight" would probably help this situation.

In other words, typing or any other recognised symbol sets state "has opened something", and waits for "/mouse-button/u/d/r/pgdn/pgup/end/home/tab" before refreshing any highlighting.

Edit: This would still "highlight the rest of the page" for a multiline template, but would solve it for the common cases of links/bold/italics which are going to be closed very soon.

It would be technically possible to "keep note of what has been typed since opening the element" and extend the functionality to "don't highlight until the cursor is placed outside of the new content", and through that allow for the enter key to be pressed when adding a multi-line template - but that would be a little more complicated, and be useful to fewer people, whereas just addressing the behaviour for links/bold/italics would be useful to everyone.

Edit: additionally, every time the highlight update runs, it uses cycles, and lags on large pages, reducing the number of times the highlight is refreshed is a good thing.