From 388c625e4746fa479a63e9cd69779a48cdfae3d6 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 3 Jan 2016 18:27:34 +0100 Subject: [PATCH] '{0}' label is not shown anymore Previously, '{0}' would be labelled as '-1 Times', which is not actually the case. Also I am not sure to best visualize such a pattern, right now, except for the label, 'a{0}' looks similar to 'a?', even though they don't have the same effect. --- spec/parser/javascript/repeat_spec.js | 12 ++++++++++++ src/js/parser/javascript/repeat.js | 3 +++ 2 files changed, 15 insertions(+) diff --git a/spec/parser/javascript/repeat_spec.js b/spec/parser/javascript/repeat_spec.js index f3fc132..147145d 100644 --- a/spec/parser/javascript/repeat_spec.js +++ b/spec/parser/javascript/repeat_spec.js @@ -54,6 +54,13 @@ describe('parser/javascript/repeat.js', function() { hasSkip: false, hasLoop: false }, + '{0}': { + minimum: 0, + maximum: 0, + greedy: true, + hasSkip: true, + hasLoop: false + }, '{1}?': { minimum: 1, maximum: 1, @@ -202,6 +209,11 @@ describe('parser/javascript/repeat.js', function() { maximum: -1, label: undefined }, + { + minimum: 0, + maximum: 0, + label: undefined + }, { minimum: 2, maximum: -1, diff --git a/src/js/parser/javascript/repeat.js b/src/js/parser/javascript/repeat.js index e753d02..715d888 100644 --- a/src/js/parser/javascript/repeat.js +++ b/src/js/parser/javascript/repeat.js @@ -33,6 +33,9 @@ export default { label: { get: function() { if (this.minimum === this.maximum) { + if (this.minimum === 0) { + return undefined; + } return formatTimes(this.minimum - 1); } else if (this.minimum <= 1 && this.maximum >= 2) { return `at most ${formatTimes(this.maximum - 1)}`;