mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:29:04 +01:00
Fixes #3494: [snippets] [debt] don't allow snippet syntax in default values
This commit is contained in:
@@ -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));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user