Skip to content

Commit

Permalink
fix: always calculate start position
Browse files Browse the repository at this point in the history
  • Loading branch information
Duologic committed Mar 14, 2024
1 parent 15ca1a8 commit be8e887
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/server/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ func createCompletionItem(label, prefix string, kind protocol.CompletionItemKind
insertText := formatLabel("['" + label + "']" + paramsString)

concat := ""
characterStartPosition := position.Character - 1
if prefix != "" && !strings.HasPrefix(insertText, "[") {
concat = "."
characterStartPosition = position.Character
}
detail := prefix + concat + insertText

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

// Remove leading `.` character when quoting label
if !mustNotQuoteLabel {
log.Print(len(prefix))
item.TextEdit = &protocol.TextEdit{
Range: protocol.Range{
Start: protocol.Position{
Line: position.Line,
Character: position.Character - 1,
Character: characterStartPosition,
},
End: protocol.Position{
Line: position.Line,
Expand Down

0 comments on commit be8e887

Please sign in to comment.