From 28d232680866c76dfab8c0ea487fec7f72d4ef90 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 13 Jun 2025 19:08:11 -0400 Subject: [PATCH] [mv3] Better support for toggling line comments --- platform/mv3/extension/js/develop.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/platform/mv3/extension/js/develop.js b/platform/mv3/extension/js/develop.js index 5d70aac98..517647d1b 100644 --- a/platform/mv3/extension/js/develop.js +++ b/platform/mv3/extension/js/develop.js @@ -484,7 +484,7 @@ class Editor { } gutterClick(view, info) { - const reSeparator = /^---\s*/; + const reSeparator = /^(?:---|# ---)\s*/; const { doc } = view.state; const lineFirst = doc.lineAt(info.from); if ( lineFirst.text === '' ) { return false; } @@ -547,6 +547,11 @@ class Editor { return { scope: 0 }; }, token: (stream, state) => { + if ( stream.sol() ) { + if ( stream.match(/^---\s*$/) ) { return 'meta'; } + if ( stream.match(/^# ---\s*$/) ) { return 'meta comment'; } + if ( stream.match(/\.\.\.\s*$/) ) { return 'meta'; } + } const c = stream.peek(); if ( c === '#' ) { if ( (stream.pos === 0 || /\s/.test(stream.string.charAt(stream.pos - 1))) ) { @@ -554,10 +559,6 @@ class Editor { return 'comment'; } } - if ( stream.sol() ) { - if ( stream.match(/---\s*$/) ) { return 'meta'; } - if ( stream.match(/\.\.\.\s*$/) ) { return 'meta'; } - } if ( stream.eatSpace() ) { return null; }