@@ -2251,7 +2251,7 @@ describe('Auto Completion Tests', () => {
2251
2251
expect ( completion . items [ 0 ] . insertText ) . eq ( 'prop2: ' ) ;
2252
2252
} ) ;
2253
2253
2254
- it ( 'should complete properties of an object under a list ' , async ( ) => {
2254
+ it ( 'should complete properties of an object under an array ' , async ( ) => {
2255
2255
schemaProvider . addSchema ( SCHEMA_ID , {
2256
2256
type : 'object' ,
2257
2257
properties : {
@@ -2269,15 +2269,51 @@ describe('Auto Completion Tests', () => {
2269
2269
} ,
2270
2270
} ,
2271
2271
} ,
2272
+ name : {
2273
+ type : 'string' ,
2274
+ } ,
2272
2275
} ,
2273
2276
} ) ;
2274
2277
2278
+ // Thanks to the indentation, the intent is clear: continue adding to the current object.
2275
2279
const content = 'steps:\n- task: PowerShell@2\n ' ; // len: 30
2276
2280
const completion = await parseSetup ( content , 30 ) ;
2277
2281
expect ( completion . items ) . lengthOf ( 1 ) ;
2278
2282
expect ( completion . items [ 0 ] . label ) . eq ( 'inputs' ) ;
2279
2283
} ) ;
2280
2284
2285
+ it ( 'should not show bare property completions for array items when the cursor indentation is ambiguous' , async ( ) => {
2286
+ schemaProvider . addSchema ( SCHEMA_ID , {
2287
+ type : 'object' ,
2288
+ properties : {
2289
+ steps : {
2290
+ type : 'array' ,
2291
+ items : {
2292
+ type : 'object' ,
2293
+ properties : {
2294
+ task : {
2295
+ type : 'string' ,
2296
+ } ,
2297
+ inputs : {
2298
+ type : 'string' ,
2299
+ } ,
2300
+ } ,
2301
+ } ,
2302
+ } ,
2303
+ name : {
2304
+ type : 'string' ,
2305
+ } ,
2306
+ } ,
2307
+ } ) ;
2308
+
2309
+ // Here, the intent _could_ be to move out of the array, or it could be to continue adding to the array.
2310
+ // Thus, `name: ` is fine and so is `- task: `, but _not_ a bare `task: `.
2311
+ const content = 'steps:\n- task: PowerShell@2\n' ; // len: 28
2312
+ const completion = await parseSetup ( content , 28 ) ;
2313
+ expect ( completion . items [ 0 ] . label ) . eq ( 'name' ) ;
2314
+ expect ( completion . items . slice ( 1 ) . filter ( ( item ) => ! item . insertText . startsWith ( '- ' ) ) ) . to . be . empty ;
2315
+ } ) ;
2316
+
2281
2317
it ( 'should complete string which contains number in default value' , async ( ) => {
2282
2318
schemaProvider . addSchema ( SCHEMA_ID , {
2283
2319
type : 'object' ,
0 commit comments