File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
src/languageservice/services Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -773,6 +773,7 @@ export class YAMLCompletion extends JSONCompletion {
773773 let insertText = '' ;
774774 if ( ! schema ) {
775775 insertText = `$${ insertIndex ++ } ` ;
776+ return { insertText, insertIndex } ;
776777 }
777778 let type = Array . isArray ( schema . type ) ? schema . type [ 0 ] : schema . type ;
778779 if ( ! type ) {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import path = require('path');
1010import { createExpectedCompletion } from './utils/verifyError' ;
1111import { ServiceSetup } from './utils/serviceSetup' ;
1212import { CompletionList } from 'vscode-languageserver' ;
13+ import { expect } from 'chai' ;
1314
1415const languageSettingsSetup = new ServiceSetup ( ) . withCompletion ( ) ;
1516const languageService = configureLanguageService ( languageSettingsSetup . languageSettings ) ;
@@ -1262,6 +1263,39 @@ suite('Auto Completion Tests', () => {
12621263 } )
12631264 . then ( done , done ) ;
12641265 } ) ;
1266+
1267+ it ( 'should handle array schema without items' , async ( ) => {
1268+ languageService . addSchema ( SCHEMA_ID , {
1269+ type : 'array' ,
1270+ items : {
1271+ anyOf : [
1272+ {
1273+ type : 'object' ,
1274+ properties : {
1275+ fooBar : {
1276+ type : 'object' ,
1277+ properties : {
1278+ name : {
1279+ type : 'string' ,
1280+ } ,
1281+ aaa : {
1282+ type : 'array' ,
1283+ } ,
1284+ } ,
1285+ required : [ 'name' , 'aaa' ] ,
1286+ } ,
1287+ } ,
1288+ } ,
1289+ ] ,
1290+ } ,
1291+ } ) ;
1292+
1293+ const content = '---\n- \n' ;
1294+ const completion = await parseSetup ( content , 6 ) ;
1295+ expect ( completion . items ) . lengthOf ( 1 ) ;
1296+ expect ( completion . items [ 0 ] . label ) . eq ( 'fooBar' ) ;
1297+ expect ( completion . items [ 0 ] . insertText ) . eq ( 'fooBar:\n name: $1\n aaa:\n - $2' ) ;
1298+ } ) ;
12651299 } ) ;
12661300 } ) ;
12671301} ) ;
You can’t perform that action at this time.
0 commit comments