nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: marp-team/marp-vscode
Pull request #257 (2021-07-07 08:29:10)

Silence unknown-theme diagnostic if definition of theme directive is incompleted


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 371869e..1b177ab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,11 @@
 ### Added
 
 - `markdown.marp.newMarpMarkdown` command to create empty Marp Markdown ([#255](https://github.com/marp-team/marp-vscode/pull/255))
-- Contribution to "New File…" in File menu and welcome screen _(Experimental: Required opt-in by `workbench.welcome.experimental.startEntries` in VS Code 1.58+)_ (#255) ([#255](https://github.com/marp-team/marp-vscode/pull/255))
+- Contribution to "New File…" in File menu and welcome screen _(Experimental: Required opt-in by `workbench.welcome.experimental.startEntries` in VS Code 1.58+)_ ([#255](https://github.com/marp-team/marp-vscode/pull/255))
+
+### Fixed
+
+- Silence `unknown-theme` diagnostic if definition of theme directive is incompleted ([#257](https://github.com/marp-team/marp-vscode/pull/257))
 
 ## v1.0.3 - 2021-06-19
 
diff --git a/src/__mocks__/vscode.ts b/src/__mocks__/vscode.ts
index acc76e8..46643a9 100644
--- a/src/__mocks__/vscode.ts
+++ b/src/__mocks__/vscode.ts
@@ -74,6 +74,10 @@ export class Position {
     return new Position(this.line + lineDelta, this.character + characterDelta)
   }
 
+  isEqual(other: Position) {
+    return this.line === other.line && this.character === other.character
+  }
+
   constructor(readonly line: number, readonly character: number) {}
 }
 
diff --git a/src/diagnostics/unknown-theme.ts b/src/diagnostics/unknown-theme.ts
index 462f794..83bdcd5 100644
--- a/src/diagnostics/unknown-theme.ts
+++ b/src/diagnostics/unknown-theme.ts
@@ -35,7 +35,10 @@ export function register(
   })
 
   directiveParser.on('endParse', () => {
-    if (parsed) {
+    if (
+      parsed &&
+      (parsed.value || !parsed.range.start.isEqual(parsed.range.end))
+    ) {
       const themeSet = themes.getMarpThemeSetFor(doc)
 
       if (!themeSet.has(parsed.value)) {


Test patch:
diff --git a/src/diagnostics/unknown-theme.test.ts b/src/diagnostics/unknown-theme.test.ts
index 064d781..df118e7 100644
--- a/src/diagnostics/unknown-theme.test.ts
+++ b/src/diagnostics/unknown-theme.test.ts
@@ -69,6 +69,18 @@ describe('[Diagnostics rule] Unknown theme', () => {
       expect(register(doc('<!-- theme: uncover -->'))).toHaveLength(0)
     })
 
+    it('does not add diagnostics when the definition of theme directive is incompleted', () => {
+      expect(register(doc('<!-- theme:-->'))).toHaveLength(0)
+      expect(register(doc('<!-- theme: -->'))).toHaveLength(0)
+      expect(register(doc('<!-- theme:  -->'))).toHaveLength(0)
+      expect(register(doc('<!-- theme:\t-->'))).toHaveLength(0)
+    })
+
+    it('adds diagnostics if set empty string explicitly', () => {
+      expect(register(doc('<!-- theme: "" -->'))).toHaveLength(1)
+      expect(register(doc("<!-- theme: '' -->"))).toHaveLength(1)
+    })
+
     describe('when registered custom theme', () => {
       beforeEach(() => {
         jest