@@ -882,8 +882,8 @@ objB:
882882 } ,
883883 } ,
884884 } ;
885- languageService . addSchema ( SCHEMA_ID , schema ) ;
886- const content = 'array:\n - na | | ' ;
885+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
886+ const content = 'array:\n - obj | | ' ;
887887 const completion = await parseCaret ( content ) ;
888888
889889 expect ( completion . items . length ) . equal ( 1 ) ;
@@ -1109,6 +1109,41 @@ objB:
11091109 expect ( result . items . length ) . to . be . equal ( 1 ) ;
11101110 expect ( result . items [ 0 ] . insertText ) . to . be . equal ( 'objA:\n itemA: ' ) ;
11111111 } ) ;
1112+
1113+ it ( 'array completion - should suggest correct indent when extra spaces after cursor followed by with different array item' , async ( ) => {
1114+ schemaProvider . addSchema ( SCHEMA_ID , {
1115+ type : 'object' ,
1116+ properties : {
1117+ test : {
1118+ type : 'array' ,
1119+ items : {
1120+ type : 'object' ,
1121+ properties : {
1122+ objA : {
1123+ type : 'object' ,
1124+ required : [ 'itemA' ] ,
1125+ properties : {
1126+ itemA : {
1127+ type : 'string' ,
1128+ } ,
1129+ } ,
1130+ } ,
1131+ } ,
1132+ } ,
1133+ } ,
1134+ } ,
1135+ } ) ;
1136+ const content = `
1137+ test:
1138+ - | |
1139+ - objA:
1140+ itemA: test` ;
1141+ const result = await parseCaret ( content ) ;
1142+
1143+ expect ( result . items . length ) . to . be . equal ( 1 ) ;
1144+ expect ( result . items [ 0 ] . insertText ) . to . be . equal ( 'objA:\n itemA: ' ) ;
1145+ } ) ;
1146+
11121147 it ( 'array of arrays completion - should suggest correct indent when extra spaces after cursor' , async ( ) => {
11131148 schemaProvider . addSchema ( SCHEMA_ID , {
11141149 type : 'object' ,
@@ -1207,27 +1242,18 @@ objB:
12071242 } ,
12081243 } ;
12091244 it ( 'should get extra space compensation for the 1st prop in array object item' , async ( ) => {
1210- languageService . addSchema ( SCHEMA_ID , schema ) ;
1245+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
12111246 const content = 'array1:\n - |\n| propB: test' ;
12121247 const result = await parseCaret ( content ) ;
12131248
12141249 expect ( result . items . length ) . to . be . equal ( 1 ) ;
12151250 expect ( result . items [ 0 ] . insertText ) . to . be . equal ( 'objA:\n ' ) ;
12161251 } ) ;
12171252 it ( 'should get extra space compensation for the 1st prop in array object item - extra spaces' , async ( ) => {
1218- languageService . addSchema ( SCHEMA_ID , schema ) ;
1253+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
12191254 const content = 'array1:\n - | | \n propB: test' ;
12201255 const result = await parseCaret ( content ) ;
12211256
1222- expect ( result . items . length ) . to . be . equal ( 1 ) ;
1223- expect ( result . items [ 0 ] . insertText ) . to . be . equal ( 'objA:\n ' ) ;
1224- } ) ;
1225- // previous PR doesn't fix this
1226- it . skip ( 'should get extra space compensation for the 1st prop in array object item - extra lines' , async ( ) => {
1227- languageService . addSchema ( SCHEMA_ID , schema ) ;
1228- const content = 'array1:\n - \n |\n| propB: test' ;
1229- const result = await parseCaret ( content ) ;
1230-
12311257 expect ( result . items . length ) . to . be . equal ( 1 ) ;
12321258 expect ( result . items [ 0 ] . insertText ) . to . be . equal ( 'objA:\n ' ) ;
12331259 } ) ;
0 commit comments