Skip to content

Commit eeb1fdb

Browse files
committed
fix: always calculate start position
1 parent 70f2438 commit eeb1fdb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/server/completion.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ func createCompletionItem(label, prefix string, kind protocol.CompletionItemKind
189189
insertText := formatLabel("['" + label + "']" + paramsString)
190190

191191
concat := ""
192+
characterStartPosition := position.Character - 1
192193
if prefix != "" && !strings.HasPrefix(insertText, "[") {
193194
concat = "."
195+
characterStartPosition = position.Character
194196
}
195197
detail := prefix + concat + insertText
196198

@@ -206,11 +208,12 @@ func createCompletionItem(label, prefix string, kind protocol.CompletionItemKind
206208

207209
// Remove leading `.` character when quoting label
208210
if !mustNotQuoteLabel {
211+
log.Print(len(prefix))
209212
item.TextEdit = &protocol.TextEdit{
210213
Range: protocol.Range{
211214
Start: protocol.Position{
212215
Line: position.Line,
213-
Character: position.Character - 1,
216+
Character: characterStartPosition,
214217
},
215218
End: protocol.Position{
216219
Line: position.Line,

0 commit comments

Comments
 (0)