A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/grafana/jsonnet-language-server/commit/aebe16108ead9c44bc88fc09db3199d4ffc51534 below:

Fix double completion bug (#124) · grafana/jsonnet-language-server@aebe161 · GitHub

File tree Expand file treeCollapse file tree 6 files changed

+38

-4

lines changed

Filter options

Expand file treeCollapse file tree 6 files changed

+38

-4

lines changed Original file line number Diff line number Diff line change

@@ -87,8 +87,8 @@ func extractObjectRangesFromDesugaredObjs(vm *jsonnet.VM, desugaredObjs []*ast.D

87 87

for len(indexList) > 0 {

88 88

index := indexList[0]

89 89

indexList = indexList[1:]

90 -

partialMatchFields := partialMatchFields && len(indexList) == 0 // Only partial match on the last index. Others are considered complete

91 -

foundFields := findObjectFieldsInObjects(desugaredObjs, index, partialMatchFields)

90 +

partialMatchCurrentField := partialMatchFields && len(indexList) == 0 // Only partial match on the last index. Others are considered complete

91 +

foundFields := findObjectFieldsInObjects(desugaredObjs, index, partialMatchCurrentField)

92 92

desugaredObjs = nil

93 93

if len(foundFields) == 0 {

94 94

return nil, fmt.Errorf("field %s was not found in ast.DesugaredObject", index)

@@ -98,8 +98,8 @@ func extractObjectRangesFromDesugaredObjs(vm *jsonnet.VM, desugaredObjs []*ast.D

98 98

ranges = append(ranges, FieldToRange(*found))

99 99 100 100

// If the field is not PlusSuper (field+: value), we stop there. Other previous values are not relevant

101 -

// If partialMatchFields is true, we can continue to look for other fields

102 -

if !found.PlusSuper && !partialMatchFields {

101 +

// If partialMatchCurrentField is true, we can continue to look for other fields

102 +

if !found.PlusSuper && !partialMatchCurrentField {

103 103

break

104 104

}

105 105

}

Original file line number Diff line number Diff line change

@@ -566,6 +566,26 @@ func TestCompletion(t *testing.T) {

566 566

},

567 567

},

568 568

},

569 +

{

570 +

name: "autocomplete fix doubled index bug",

571 +

filename: "testdata/doubled-index-bug-4.jsonnet",

572 +

replaceString: "a: g.hello",

573 +

replaceByString: "a: g.hello.",

574 +

expected: protocol.CompletionList{

575 +

IsIncomplete: false,

576 +

Items: []protocol.CompletionItem{

577 +

{

578 +

Label: "to",

579 +

Kind: protocol.FieldCompletion,

580 +

Detail: "g.hello.to",

581 +

InsertText: "to",

582 +

LabelDetails: protocol.CompletionItemLabelDetails{

583 +

Description: "object",

584 +

},

585 +

},

586 +

},

587 +

},

588 +

},

569 589

}

570 590

for _, tc := range testCases {

571 591

t.Run(tc.name, func(t *testing.T) {

Original file line number Diff line number Diff line change

@@ -0,0 +1,7 @@

1 +

{

2 +

hello: {

3 +

to: {

4 +

the: 'world',

5 +

},

6 +

},

7 +

}

Original file line number Diff line number Diff line change

@@ -0,0 +1 @@

1 +

{ hello: (import 'doubled-index-bug-1.jsonnet').hello }

Original file line number Diff line number Diff line change

@@ -0,0 +1 @@

1 +

import 'doubled-index-bug-2.jsonnet'

Original file line number Diff line number Diff line change

@@ -0,0 +1,5 @@

1 +

local g = import 'doubled-index-bug-3.jsonnet';

2 +

{

3 +

// completing fields of `g.hello` should get use `g.hello.to`, not `g.hello.hello`

4 +

a: g.hello,

5 +

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4