Skip to content

Incorrect additionalTextEdit applied when auto-importing PHP namespaces #757

@pyr0hu

Description

@pyr0hu
  • OS and language server
    • macOS 10.15 -
  • How you installed LSP (Package Control or from git?)
    • Package Control
  • Minimal reproduction steps
    • create a minimal php package with autoloading
    • create a src/First and src/Second folders
    • add an App class with the appropriate namespaces, so we have e.g. Acme\First\App and Acme\Second\App
    • In a different class e.g. Acme/Start try writing App in a function. It will show two App instance, Acme\First\App and Acme\Second\App.
    • Select the second one
    • It will use the first App's additionalTextEdits and adds use Acme\First\App when I clearly selected the second (tried using tab or enter, doesnt matter)
  • Log
{'textEdit': {'range': {'end': {'character': 4, 'line': 6}, 'start': {'character': 2, 'line': 6}}, 'newText': 'App'}, 'additionalTextEdits': [{'range': {'end': {'character': 0, 'line': 4}, 'start': {'character': 22, 'line': 2}}, 'newText': '\n\nuse Acme\\Test\\App;\n\n'}], 'kind': 7, 'detail': 'use Acme\\Test\\App', 'sortText': 'App', 'label': 'App', 'data': 1264852955825781},
{'textEdit': {'range': {'end': {'character': 4, 'line': 6}, 'start': {'character': 2, 'line': 6}}, 'newText': 'App'}, 'additionalTextEdits': [{'range': {'end': {'character': 0, 'line': 4}, 'start': {'character': 22, 'line': 2}}, 'newText': '\n\nuse Acme\\Third\\App;\n\n'}], 'kind': 7, 'detail': 'use Acme\\Third\\App', 'sortText': 'App', 'label': 'App', 'data': 4436429581058069}

From the logs, it's clearly seen that the use expression is correct for the different classes. It just that it always uses the first one and there is no way to import the second namespace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions