Skip to content

Completion result have "typeParameter" duplicates  #273

Closed
@masad-frost

Description

@masad-frost

Completion items keep including duplicate items, but one of them has object at the end of the label.

Here is an example request, with document print

Expand to see request. Trigger completion after `print` ```json { "method": "textDocument/completion", "params": { "textDocument": { "uri": "file:///home/user/dir/main.py" }, "position": { "line": 0, "character": 5 }, "context": { "triggerKind": 1 } }, "id": 1200384153, "jsonrpc": "2.0" } ```
Expand to see result
{
  "isIncomplete": false,
  "items": [
    {
      "label": "print(values, sep, end, file, flush)",
      "kind": 3,
      "sortText": "aprint",
      "insertText": "print",
      "data": {
        "doc_uri": "file:///home/runner/ExtraneousExcitedWebsites/main.py"
      }
    },
    {
      "label": "print(values, sep, end, file, flush) object",
      "kind": 25,
      "sortText": "aprint",
      "insertText": "print",
      "data": {
        "doc_uri": "file:///home/runner/ExtraneousExcitedWebsites/main.py"
      }
    }
  ]
}
Expand to see initialization options ```json { "method": "initialize", "params": { "capabilities": { "textDocument": { "synchronization": { "dynamicRegistration": true, "didSave": true }, "signatureHelp": { "dynamicRegistration": true, "signatureInformation": { "documentationFormat": [ "plaintext", "markdown" ] } }, "publishDiagnostics": { "relatedInformation": true }, "formatting": { "dynamicRegistration": true }, "documentSymbol": { "dynamicRegistration": true, "hierarchicalDocumentSymbolSupport": true, "symbolKind": { "valueSet": [ 18, 17, 5, 14, 9, 10, 22, 24, 8, 1, 12, 11, 20, 6, 2, 3, 19, 25, 4, 7, 15, 23, 26, 13 ] } }, "definition": { "dynamicRegistration": true }, "typeDefinition": { "dynamicRegistration": true }, "implementation": { "dynamicRegistration": true }, "references": { "dynamicRegistration": true }, "rename": { "dynamicRegistration": true, "prepareSupport": true }, "completion": { "dynamicRegistration": true, "completionItem": { "documentationFormat": [ "plaintext", "markdown" ], "snippetSupport": true } }, "codeAction": { "dynamicRegistration": true, "codeActionLiteralSupport": { "codeActionKind": { "valueSet": [ "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports", "source.fixAll" ] } } }, "hover": { "dynamicRegistration": true, "contentFormat": [ "plaintext" ] } }, "workspace": { "applyEdit": true, "configuration": true, "executeCommand": { "dynamicRegistration": true }, "workspaceEdit": { "documentChanges": true, "resourceOperations": [ "create", "delete", "rename" ] } } }, "processId": null, "rootUri": "file:///home/runner/ExtraneousExcitedWebsites", "workspaceFolders": [ { "name": "file:///home/runner/ExtraneousExcitedWebsites", "uri": "file:///home/runner/ExtraneousExcitedWebsites" } ] }, "id": 79703483, "jsonrpc": "2.0" } ```

I found this in the codebase

if include_class_objects:
for i, c in enumerate(completions):
if c.type == 'class':
completion_dict = _format_completion(
c,
markup_kind=preferred_markup_kind,
include_params=False,
resolve=resolve_eagerly,
resolve_label_or_snippet=(i < max_to_resolve)
)
completion_dict['kind'] = lsp.CompletionItemKind.TypeParameter
completion_dict['label'] += ' object'
ready_completions.append(completion_dict)
if include_function_objects:
for i, c in enumerate(completions):
if c.type == 'function':
completion_dict = _format_completion(
c,
False,
resolve=resolve_eagerly,
resolve_label_or_snippet=(i < max_to_resolve)
)
completion_dict['kind'] = lsp.CompletionItemKind.TypeParameter
completion_dict['label'] += ' object'
ready_completions.append(completion_dict)

Not sure what is the point of it.

Some guidance and I'll happily fix the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions