Fixes #3494: [snippets] [debt] don't allow snippet syntax in default values

This commit is contained in:
Martin Aeschlimann
2016-02-29 22:29:09 +01:00
parent c676ceb733
commit f0c6ccccce
19 changed files with 227 additions and 135 deletions

View File

@@ -24,7 +24,7 @@ suite('JSON Completion', () => {
var matches = completions.filter(function(completion: CompletionItem) {
return completion.label === label && (!documentation || completion.documentation === documentation);
});
assert.equal(matches.length, 1, label + " should only existing once");
assert.equal(matches.length, 1, label + " should only existing once: Actual: " + completions.map(c => c.label).join(', '));
if (document && resultText) {
assert.equal(applyEdits(document, [ matches[0].textEdit ]), resultText);
}
@@ -51,8 +51,6 @@ suite('JSON Completion', () => {
})
};
test('Complete keys no schema', function(testDone) {
Promise.all([
testSuggestionsFor('[ { "name": "John", "age": 44 }, { /**/ }', '/**/', null, result => {
@@ -478,4 +476,44 @@ suite('JSON Completion', () => {
}),
]).then(() => testDone(), (error) => testDone(error));
});
});
test('Escaping no schema', function(testDone) {
Promise.all([
testSuggestionsFor('[ { "\\\\{{}}": "John" }, { "/**/" }', '/**/', null, result => {
assertSuggestion(result, '\\{{}}');
}),
testSuggestionsFor('[ { "\\\\{{}}": "John" }, { /**/ }', '/**/', null, (result, document) => {
assertSuggestion(result, '\\{{}}', null, document, '[ { "\\\\{{}}": "John" }, { "\\\\\\\\\\{\\{\\}\\}"/**/ }');
}),
testSuggestionsFor('[ { "name": "\\{" }, { "name": /**/ }', '/**/', null, result => {
assertSuggestion(result, '"\\{"');
})
]).then(() => testDone(), (error) => testDone(error));
});
test('Escaping with schema', function(testDone) {
var schema: JsonSchema.IJSONSchema = {
type: 'object',
properties: {
'{\\}': {
default: "{\\}",
defaultSnippets: [ { body: "{{var}}"} ],
enum: ['John{\\}']
}
}
};
Promise.all([
testSuggestionsFor('{ /**/ }', '/**/', schema, (result, document) => {
assertSuggestion(result, '{\\}', null, document, '{ "\\{\\\\\\\\\\}": "{{\\{\\\\\\\\\\}}}"/**/ }');
}),
testSuggestionsFor('{ "{\\\\}": /**/ }', '/**/', schema, (result, document) => {
assertSuggestion(result, '"{\\\\}"', null, document, '{ "{\\\\}": "\\{\\\\\\\\\\}"/**/ }');
assertSuggestion(result, '"John{\\\\}"', null, document, '{ "{\\\\}": "John\\{\\\\\\\\\\}"/**/ }');
assertSuggestion(result, '"var"', null, document, '{ "{\\\\}": "{{var}}"/**/ }');
})
]).then(() => testDone(), (error) => testDone(error));
});
});