Skip to content

Commit

Permalink
refactor: always use TextEdit
Browse files Browse the repository at this point in the history
  • Loading branch information
Duologic committed Mar 11, 2024
1 parent 93cd2e2 commit dead763
Show file tree
Hide file tree
Showing 2 changed files with 315 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pkg/server/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,15 @@ func createCompletionItem(label, prefix string, kind protocol.CompletionItemKind
}
detail := prefix + concat + insertText

item := protocol.CompletionItem{
return protocol.CompletionItem{
Label: label,
Detail: detail,
Kind: kind,
LabelDetails: protocol.CompletionItemLabelDetails{
Description: typeToString(body),
},
InsertText: insertText,
}

if strings.HasPrefix(insertText, "[") {
item.TextEdit = &protocol.TextEdit{
TextEdit: &protocol.TextEdit{
Range: protocol.Range{
Start: protocol.Position{
Line: position.Line,
Expand All @@ -220,10 +217,8 @@ func createCompletionItem(label, prefix string, kind protocol.CompletionItemKind
},
},
NewText: insertText,
}
},
}

return item
}

func typeToString(t ast.Node) string {
Expand Down
Loading

0 comments on commit dead763

Please sign in to comment.