Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect additionalTextEdit applied when auto-importing PHP namespaces #757

Closed
pyr0hu opened this issue Oct 23, 2019 · 8 comments
Closed

Comments

@pyr0hu
Copy link

pyr0hu commented Oct 23, 2019

  • 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

@tomv564
Copy link
Contributor

tomv564 commented Oct 26, 2019

Sorry, but this cannot be fixed with sublime’s completion API - it does not tell us which completion item was chosen/inserted. Our workaround does a lookup by inserted string, but obviously cannot differentiate between your two ‘App’ imports.

Thanks for the detailed report, hope it’s workable for you otherwise!

@tomv564 tomv564 added sublime issue Issues related to shortcomings or bugs in the ST API wontfix labels Oct 26, 2019
@tomv564 tomv564 closed this as completed Oct 26, 2019
@predragnikolic
Copy link
Member

Can the new Sublime api for autocompleton handle this? If so can we reopen the issue?

@ayoub-benali
Copy link
Contributor

Yes the new API allows to fix this issue. I would re-open as well but label it for ST4

@tomv564
Copy link
Contributor

tomv564 commented Nov 30, 2019

Good point, I guess you are referring to using a command with the completion item?

I like to keep the issue list as relevant as possible, so I personally don't see the point of opening this issue until manpower shows up to work on ST4000 features.

@ayoub-benali
Copy link
Contributor

yes the completion item. I am willing to work on this topic, can we have a st4000 branch along side master ?

@tomv564
Copy link
Contributor

tomv564 commented Nov 30, 2019

Yes, feel free to create a PR to the st4000-exploration branch.

@tomv564 tomv564 reopened this Nov 30, 2019
@ayoub-benali
Copy link
Contributor

Thanks

@rwols rwols removed sublime issue Issues related to shortcomings or bugs in the ST API wontfix labels Dec 2, 2019
@rwols
Copy link
Member

rwols commented Mar 29, 2020

Supposedly fixed by #866 (won't be available for ST3).

@rwols rwols closed this as completed Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants