Skip to content

Commit 28d2326

Browse files
committed
[mv3] Better support for toggling line comments
1 parent 786cf0c commit 28d2326

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

platform/mv3/extension/js/develop.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ class Editor {
484484
}
485485

486486
gutterClick(view, info) {
487-
const reSeparator = /^---\s*/;
487+
const reSeparator = /^(?:---|# ---)\s*/;
488488
const { doc } = view.state;
489489
const lineFirst = doc.lineAt(info.from);
490490
if ( lineFirst.text === '' ) { return false; }
@@ -547,17 +547,18 @@ class Editor {
547547
return { scope: 0 };
548548
},
549549
token: (stream, state) => {
550+
if ( stream.sol() ) {
551+
if ( stream.match(/^---\s*$/) ) { return 'meta'; }
552+
if ( stream.match(/^# ---\s*$/) ) { return 'meta comment'; }
553+
if ( stream.match(/\.\.\.\s*$/) ) { return 'meta'; }
554+
}
550555
const c = stream.peek();
551556
if ( c === '#' ) {
552557
if ( (stream.pos === 0 || /\s/.test(stream.string.charAt(stream.pos - 1))) ) {
553558
stream.skipToEnd();
554559
return 'comment';
555560
}
556561
}
557-
if ( stream.sol() ) {
558-
if ( stream.match(/---\s*$/) ) { return 'meta'; }
559-
if ( stream.match(/\.\.\.\s*$/) ) { return 'meta'; }
560-
}
561562
if ( stream.eatSpace() ) {
562563
return null;
563564
}

0 commit comments

Comments
 (0)