zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
24.96k stars 1.17k forks source link

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

Open mzoliker opened 8 months ago

mzoliker commented 8 months ago

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

JoeKar commented 8 months ago

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.

mzoliker commented 8 months ago

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…

JoeKar commented 8 months ago

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).