@@ -454,28 +454,6 @@ func TestCompletion(t *testing.T) {
454
454
},
455
455
},
456
456
},
457
- // TODO: This one doesn't work yet
458
- // Issue: https://github.com/grafana/jsonnet-language-server/issues/113
459
- // {
460
- // name: "autocomplete local at root 2",
461
- // filename: "testdata/local-at-root-2.jsonnet",
462
- // replaceString: "hello.to",
463
- // replaceByString: "hello.",
464
- // expected: protocol.CompletionList{
465
- // IsIncomplete: false,
466
- // Items: []protocol.CompletionItem{
467
- // {
468
- // Label: "to",
469
- // Kind: protocol.FieldCompletion,
470
- // Detail: "hello.to",
471
- // InsertText: "to",
472
- // LabelDetails: protocol.CompletionItemLabelDetails{
473
- // Description: "object",
474
- // },
475
- // },
476
- // },
477
- // },
478
- // },
479
457
{
480
458
// This checks that we don't match on `hello.hello.*` if we autocomplete on `hello.hel.`
481
459
name : "autocomplete local at root, no partial match if full match exists" ,
@@ -508,6 +486,86 @@ func TestCompletion(t *testing.T) {
508
486
Items : nil ,
509
487
},
510
488
},
489
+ {
490
+ name : "autocomplete local at root 2" ,
491
+ filename : "testdata/local-at-root-2.jsonnet" ,
492
+ replaceString : "hello.to" ,
493
+ replaceByString : "hello." ,
494
+ expected : protocol.CompletionList {
495
+ IsIncomplete : false ,
496
+ Items : []protocol.CompletionItem {
497
+ {
498
+ Label : "to" ,
499
+ Kind : protocol .FieldCompletion ,
500
+ Detail : "hello.to" ,
501
+ InsertText : "to" ,
502
+ LabelDetails : protocol.CompletionItemLabelDetails {
503
+ Description : "object" ,
504
+ },
505
+ },
506
+ },
507
+ },
508
+ },
509
+ {
510
+ name : "autocomplete local at root 2, nested" ,
511
+ filename : "testdata/local-at-root-2.jsonnet" ,
512
+ replaceString : "hello.to" ,
513
+ replaceByString : "hello.to." ,
514
+ expected : protocol.CompletionList {
515
+ IsIncomplete : false ,
516
+ Items : []protocol.CompletionItem {
517
+ {
518
+ Label : "the" ,
519
+ Kind : protocol .FieldCompletion ,
520
+ Detail : "hello.to.the" ,
521
+ InsertText : "the" ,
522
+ LabelDetails : protocol.CompletionItemLabelDetails {
523
+ Description : "object" ,
524
+ },
525
+ },
526
+ },
527
+ },
528
+ },
529
+ {
530
+ name : "autocomplete local at root 3, import chain" ,
531
+ filename : "testdata/local-at-root-3.jsonnet" ,
532
+ replaceString : "hello2.the" ,
533
+ replaceByString : "hello2." ,
534
+ expected : protocol.CompletionList {
535
+ IsIncomplete : false ,
536
+ Items : []protocol.CompletionItem {
537
+ {
538
+ Label : "the" ,
539
+ Kind : protocol .FieldCompletion ,
540
+ Detail : "hello2.the" ,
541
+ InsertText : "the" ,
542
+ LabelDetails : protocol.CompletionItemLabelDetails {
543
+ Description : "object" ,
544
+ },
545
+ },
546
+ },
547
+ },
548
+ },
549
+ {
550
+ name : "autocomplete local at root 4, import chain" ,
551
+ filename : "testdata/local-at-root-4.jsonnet" ,
552
+ replaceString : "hello3.world" ,
553
+ replaceByString : "hello3." ,
554
+ expected : protocol.CompletionList {
555
+ IsIncomplete : false ,
556
+ Items : []protocol.CompletionItem {
557
+ {
558
+ Label : "world" ,
559
+ Kind : protocol .FieldCompletion ,
560
+ Detail : "hello3.world" ,
561
+ InsertText : "world" ,
562
+ LabelDetails : protocol.CompletionItemLabelDetails {
563
+ Description : "string" ,
564
+ },
565
+ },
566
+ },
567
+ },
568
+ },
511
569
}
512
570
for _ , tc := range testCases {
513
571
t .Run (tc .name , func (t * testing.T ) {
0 commit comments