Syntax highlighting breaks when pasting identical text over selected text

Often times, when I want to copy/paste some code template (to add a new clause to an if statement, another entry to a table, a similar block of code that uses the same boilerplate as the code block before it), I select the text I want to copy, hit ctrl+c to copy it, then hit ctrl+v twice as a very quick way to move my cursor down by pasting over my selection, then pasting again under my selection. It’s sort of become a habit at this point.

With the recent syntax highlighting update, this breaks all of the syntax highlighting in the area I selected when I do this, and it’s really annoying, because it slows down my workflow.

Video showcasing how to reproduce the bug (using the context menu instead of ctrl+c and ctrl+v to show what is happening more clearly; my mouse cursor appears offset in the recording due to a ShareX bug):

This is what it looks like when I’m using keyboard shortcuts (it’s just a quick and ergonomic force of habit for me):

8 Likes

Thank you for the report, this issue is fixed internally.

5 Likes

Moving replies to this post in from another topic

2 Likes

Do you have a repro case for the pictured syntax highlighting bug? I would very much like to take a look at it.

5 Likes

I had talked to @darkmodeonn about it, but basically copy and pasting the same code over itself (100% repro). It can also occur with cut and paste and it can also occur with comments and creating a new line (not 100%, seemingly random). A lot of weird ways it can occur.

1 Like

Thank you. :slight_smile: The copy pasting code over itself has been fixed internally; that particular bug should disappear soon.

We will investigate the comment/newline case. In this scenario, does the problem correct itself if you modify the incorrectly highlighted line, or does it persist?

4 Likes

It persists until you close and reopen the script. It either disregards ALL syntax highlighting and goes completely grey, or highlights everything improperly and randomly.

1 Like

Thank you, that information is very helpful. One more question: When the script editor is in this broken state, does auto-formatting work?

2 Likes

I don’t believe it does. It acts like a text file.

(Also could a mod move this side convo to the original syntax announcement/beta thread?)

1 Like