Skip to content

Commit

Permalink
Skip matching partial if value does not match
Browse files Browse the repository at this point in the history
  • Loading branch information
aholstenson committed Feb 3, 2017
1 parent 5472f41 commit 43f9111
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
12 changes: 1 addition & 11 deletions resolver/value.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,7 @@ class Value extends Node {
if(encounter.partial) {
if(idx >= stop) {
// There are no tokens available for this value, assume it will match in the future
return encounter.next(1.0, 0);
} else if(idx == stop - 1) {
promise = promise.then(() => {
if(results.length > 0) return;

// The parsing of the value failed somehow, assume we will match when the user keeps typing
return encounter.next(1.0, 1)
.then(matches => {
results.push(...matches);
});
});
return encounter.next(0.0, 0);
}
}

Expand Down
8 changes: 1 addition & 7 deletions test/resolver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,7 @@ describe('Resolver', function() {
return resolver.match('hello cookie', {
partial: true
}).then(r => {
expect(r.matches.length).to.equal(1);
expect(r.best.values.test).to.equal(undefined);
expect(r.best.expression[1]).to.deep.equal({
type: 'value',
id: 'test',
value: null
});
expect(r.matches.length).to.equal(0);
})
});
});
Expand Down

0 comments on commit 43f9111

Please sign in to comment.