Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 21faa6c

Browse files
committedApr 30, 2024
fix: make challenge fail when lines match incompletely but should not match at all
1 parent ca83c21 commit 21faa6c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed
 

‎_layouts/tutorial.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
content: "{{ site.data.localization.match.matchedIncompletely[page.lang] }}";
4040
}
4141

42+
.playfield.verbose .incompletematch.fail:after {
43+
content: "{{ site.data.localization.match.shouldNotMatch[page.lang] }}";
44+
}
45+
4246
.playfield.verbose .match.ok:after {
4347
content: "{{ site.data.localization.match.matched[page.lang] }}";
4448
}

‎css/playfield.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
.playfield .incompletematch.ok {
5555
background-color: {{ site.data.colors.fails }};
5656
}
57+
.playfield .incompletematch.fail {
58+
background-color: {{ site.data.colors.fails }};
59+
}
5760
.playfield .nomatch.ok {
5861
background-color: {{ site.data.colors.fails }};
5962
}

‎js/playfield.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ function watchExpression(playfield, examples, regex, message) {
119119

120120
matchExample(match, isIncomplete, text, example);
121121

122-
// enforce overall result to fail if any match is incomplete
123-
match = !isIncomplete;
122+
// enforce overall result to fail if any expected match is incomplete
123+
if (referenceInfo.shouldMatchWholeLine && !shouldNotMatch)
124+
match = match && !isIncomplete;
124125
} else {
125126
unmatchExample(example);
126127
}

0 commit comments

Comments
 (0)
Please sign in to comment.