[mv3] Better support for toggling line comments

This commit is contained in:
Raymond Hill 2025-06-13 19:08:11 -04:00
parent 786cf0c802
commit 28d2326808
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -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;
}