From 9c08e902bddcd5f424928c38d65c7b87f5c59336 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 24 Jun 2025 20:44:14 -0400 Subject: [PATCH] [mv3] Fix regression in syntax highlighting of dark theme --- platform/mv3/extension/css/develop.css | 27 +++++++++++++++++-- platform/mv3/extension/js/develop.js | 26 +++++++++--------- .../extension/lib/codemirror/codemirror-ubol | 2 +- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/platform/mv3/extension/css/develop.css b/platform/mv3/extension/css/develop.css index 7f2eb00e8..55816b6d6 100644 --- a/platform/mv3/extension/css/develop.css +++ b/platform/mv3/extension/css/develop.css @@ -31,12 +31,35 @@ section[data-pane="develop"] > div > * { height: 100%; } -#cm-container .cm-editor .cm-line:has(.yamlboundary) { +#cm-container .cm-editor .cm-line:has(.ubol-boundary) { background-image: url('line-hor-dashed.png'), url('line-hor-dashed.png'); background-position: left 3px, left calc(100% - 3px); background-repeat: repeat-x; } - +#cm-container .cm-editor { + color: var(--ink-1); + } +:root.dark #cm-container .cm-editor { + color: var(--ink-2); + } +#cm-container .cm-editor .cm-line .ubol-comment { + color: #ba5300; + } +:root.dark #cm-container .cm-editor .cm-line .ubol-comment { + color: #fa7000; + } +#cm-container .cm-editor .cm-line .ubol-keyword { + color: #ae42be; + } +:root.dark #cm-container .cm-editor .cm-line .ubol-keyword { + color: #ea59ff; + } +#cm-container .cm-editor .cm-line .ubol-literal { + color: #168156; + } +:root.dark #cm-container .cm-editor .cm-line .ubol-literal { + color: #1dae74; + } #cm-container .cm-editor .cm-line.badline:not(.cm-activeLine) { background-color: color-mix(in srgb, var(--info3-ink) 15%, transparent 85%); } diff --git a/platform/mv3/extension/js/develop.js b/platform/mv3/extension/js/develop.js index e36240a27..0413c708f 100644 --- a/platform/mv3/extension/js/develop.js +++ b/platform/mv3/extension/js/develop.js @@ -557,35 +557,33 @@ class Editor { }, token: (stream, state) => { if ( stream.sol() ) { - if ( stream.match(/^---\s*$/) ) { return 'yamlboundary'; } - if ( stream.match(/^# ---\s*$/) ) { return 'yamlboundary comment'; } - if ( stream.match(/\.\.\.\s*$/) ) { return 'yamlboundary'; } + if ( stream.match(/^---\s*$/) ) { return 'ubol-boundary'; } + if ( stream.match(/^# ---\s*$/) ) { return 'ubol-boundary ubol-comment'; } + if ( stream.match(/\.\.\.\s*$/) ) { return 'ubol-boundary'; } } const c = stream.peek(); if ( c === '#' ) { if ( (stream.pos === 0 || /\s/.test(stream.string.charAt(stream.pos - 1))) ) { stream.skipToEnd(); - return 'comment'; + return 'ubol-comment'; } } - if ( stream.eatSpace() ) { - return null; - } + if ( stream.eatSpace() ) { return null; } const { scope } = state; state.scope = 0; if ( scope === 0 && stream.match(/^[^:]+(?=:)/) ) { state.scope = 1; - return 'keyword'; + return 'ubol-keyword'; } if ( scope === 1 && stream.match(/^:(?: |$)/) ) { - return 'punctuation'; + return 'ubol-punctuation'; } if ( stream.match(/^- /) ) { - return 'punctuation'; + return 'ubol-punctuation'; } if ( this.editor.streamParserKeywords ) { if ( stream.match(this.editor.streamParserKeywords) ) { - return 'literal'; + return 'ubol-literal'; } } if ( stream.match(/^\S+/) ) { @@ -598,7 +596,11 @@ class Editor { commentTokens: { line: '#' }, }, tokenTable: [ - 'yamlboundary', + 'ubol-boundary', + 'ubol-keyword', + 'ubol-comment', + 'ubol-punctuation', + 'ubol-literal', ], }; } diff --git a/platform/mv3/extension/lib/codemirror/codemirror-ubol b/platform/mv3/extension/lib/codemirror/codemirror-ubol index 4bacc0ca7..0cd9b7a77 160000 --- a/platform/mv3/extension/lib/codemirror/codemirror-ubol +++ b/platform/mv3/extension/lib/codemirror/codemirror-ubol @@ -1 +1 @@ -Subproject commit 4bacc0ca79f3eb4c6e395bf54d3f5efe4da4e07c +Subproject commit 0cd9b7a77cd166186ebdb483d6aac82f616685df