micro icon indicating copy to clipboard operation
micro copied to clipboard

Javascript regex with string delimiter (" or ' or `) breaks syntax highlighting

Open mzoliker opened this issue 1 year ago • 3 comments

Description of the problem or steps to reproduce

Open a .js file and any line below will break syntax highlighting: let a = /"/; let a = /'/; let a = /`/; let a = /["'ˋ]/;

Specifications

Version: 2.0.13 Commit hash: 68d88b57 Compiled on October 21, 2023 OS: Ubuntu

mzoliker avatar Feb 01 '24 17:02 mzoliker

This is not only a "problem" with the javascript.yaml syntax definition, but all syntax definitions using regions instead. These region start and end patterns are normally not defined to respect their usage within self written regex statements. The only generic approach would be to define a regex region. This is done by Vim too.

JoeKar avatar Feb 01 '24 22:02 JoeKar

Why not implement/use sublime syntax files? This is very robust and would solve all micro’s issues with syntax highlighting. https://www.sublimetext.com/docs/syntax.html Unfortunately, unreliable syntax highlighting is a real show stopper for me, despite all advantages of micro…

mzoliker avatar Feb 02 '24 23:02 mzoliker

Why not implement/use sublime syntax files?

The current syntax highlighting approach is a bit simpler. Adding a more complex and most probably more accurate one (e.g. like SublimeText) would take a lot of time. The parsing and syntax highlighting engine then need to be changed/rewritten, to support such complex definitions...even when it's already inspired by something like this. It's a question of where micro would like to go and resources available for micro. As of now only some volunteers provide some fixes and features, but it takes a lot of time till they're merged (have a look at my open PRs for example).

JoeKar avatar Feb 03 '24 16:02 JoeKar