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

Autocomplete does not automatically show suggestions due to prefix override workaround #501

Closed
machitgarha opened this issue Apr 5, 2020 · 22 comments · Fixed by #521
Closed

Comments

@machitgarha
Copy link
Collaborator

machitgarha commented Apr 5, 2020

Hi. First of all, thanks for this cool package in Atom. Everything works fine, except the auto-completion.

Desciption

When I type characters like $, :: or ->, the suggestions will be shown in a great way, but when I enter another character to limit the suggestions, all Serenata suggestions will be disappeared (yes, the default snippets are shown). However, all of expected suggestions will be re-shown when I enter Ctrl+Space.

Example

To be clarified, in the following example, minimumWordLength equals 3 (in the settings of autocomplete-plus package):

Input Actual Result Expected Result
$this-> Expected Result => Showing all methods of current class
$this->d Expected Result => Only snippets starting with d, like debug and do
$this->de Expected Result => Only snippets starting with de, like debug and def
$this->de + Ctrl+Space Expected Result => Showing methods starting with de
$this->deb (Problem) Only snippets starting with deb, like debug Showing methods starting with deb
$this->deb + Ctrl+Space Expected Result => Showing methods starting with deb

Steps to Reproduce

Do steps in Example section above.

Platform Information

  • Operating System: Fedora Workstation 31
  • Atom: 1.44.0 (x64)
  • Packages:
    • php-ide-serenata: 5.2.0
    • atom-ide-ui: 0.13.0
    • No ide-php and the like installed.
  • PHP: 7.3.16
  • Settings:
    • autocomplete-plus:
      • minimumWordLength: 3

What should I do now?

@Gert-dev
Copy link
Owner

Hello.

Do you have minimumWordLength in the autocomplete-plus settings set to a non-zero value?

@machitgarha
Copy link
Collaborator Author

Yes, it's 3, the default one.

@Gert-dev
Copy link
Owner

Do the words your typing happen to be less than three characters when this doesn't work 😄 ? IIUC, this setting causes nothing to be autocompleted unless you've typed at least three characters. If this is indeed causing the problem, you can try setting it to 0 and see if that has any effect.

@machitgarha
Copy link
Collaborator Author

No. Sorry. Neither typing more than minimumWordLength help anything nor decreasing its value.

However, when I set it to 0, it works, but strange and somehow wrong (e.g. especially for class methods and variables). Furthermore, pressing enter for inclusion of the suggestion inserts it after what I typed, not replacing it. For example, when I type replace and I press enter when the autocomplete is active on str_replace(), then the result will be replacestr_replace(), not as expected.

BTW, I don't want minimumWordLength to be 0.

@Gert-dev
Copy link
Owner

Okay, I think I may be able to clear up some confusion: autocompletion triggers on characters such as $, :: and -> because these are so-called "trigger characters", meaning Atom will always try to show suggestions when these are typed.

If you type something after them, you fall back to "standard" autocompletion, which also happens when you start typing on a new line. If you have minimumWordLength set to 3, this means (IIUC), that Atom will not try to do any additional autocompletion anymore when you type b or be, because you have fewer than 3 characters (Atom stops counting at word boundaries).

In short, this probably happens:

  1. Type self::.
  2. Atom asks Serenata for autocompletion because :: is a trigger character.
  3. Autocompletion is shown, same as if you pressed Ctrl+Space.
  4. You type g, turning the code into self::g.
  5. Atom needs to ask the server for autocompletion suggestions again, because the input or "prefix" changed. The minimumWordLength is 3, which is larger than 1, so Atom shrugs and gives up.

I would expect this to start working when you typed 3 or more characters, then, though 😄.

@machitgarha
Copy link
Collaborator Author

@Gert-dev For clarification, I've updated the issue and added more precise details on the problem (in the Example section).

@Gert-dev
Copy link
Owner

Gert-dev commented May 31, 2020

Hmm, I understand. This does somehow appear to be linked to that minimumWordCount option. If I set it to 0 here, everything works, if I set it to the default (3), I get even different results from you and never get autocompletion unless I press ctrl-space.

The strange thing is that, on exactly the third character, even the snippets disappear. As if Atom knows there should now be other suggestions, but none are shown. If I press ctrl-space, they suddenly pop up.

I'm wondering if this is related to this fix I did. Could you perhaps try commenting it out to see if that fixes anything?

(I can say for sure that it's not a server problem, since in other clients and the server output the appropriate suggestions appear to be returned.)

@machitgarha
Copy link
Collaborator Author

machitgarha commented May 31, 2020

@Gert-dev Oh! Good to hear it does not only happen for me. And about the fix, what should I do to get the fix? Only updating to the latest version or not?

@rhuijts
Copy link

rhuijts commented Jun 6, 2020

Commenting out that line in ~/.atom/packages/php-ide-serenata/lib/SerenataClient.js fixed it for me, with the autocomplete-plus still on the minimumWordCount default of 3. It also fixed issue #489 for me, so the suggestion is no longer appended to what I already typed. It does bring back issue #487, so I will have @@inheritDoc, but that is still better than @inhe@inheritDoc.

@machitgarha
Copy link
Collaborator Author

@rhuijts Thanks for your help.

@Gert-dev Yes, commenting the mentioned line as a temporary fix worked for me too. However, I'm waiting for a permanent fix (maybe removing that line causes other issues?).

@Gert-dev
Copy link
Owner

Gert-dev commented Jun 12, 2020

Hello.

Nice to hear you found a workaround.

Indeed, I could remove the line, but it will break sorting and filtering the list, as indicated by the comment above it. Atom seems to insist on doing its own reordering and filtering client-side, whilst the autocompletion results by Serenata are already filtered and sorted server-side. This causes less relevant results to be shown or the sorting to be different than intended by the server. The only fix I've found for that so far is this line, but it seems like an upstream bug.

Seeing as removing this line fixes it, I'll update the title of this ticket to reflect that and leave it open so it's not forgotten in the future.

@Gert-dev Gert-dev changed the title Autocomplete not showing suggestions after typing, but with ctrl+space Autocomplete does not automatically show suggestions due to prefix override workaround Jun 12, 2020
@claytonrcarter
Copy link

Commenting out that line in ~/.atom/packages/php-ide-serenata/lib/SerenataClient.js also fixed this for me. Thanks!

@yanggs07
Copy link

is this bug still exists with current 5.4.0?

@machitgarha
Copy link
Collaborator Author

machitgarha commented Sep 22, 2020

@yanggs07 Still exists. As @Gert-dev has said, it seems to be an upstream bug.

@yanggs07
Copy link

@yanggs07 Still exists. As @Gert-dev has said, it seems to be an upstream bug.

emmmm so i still use v4.5.3 with osx 10.15.2, atom

@UziTech
Copy link
Contributor

UziTech commented Oct 27, 2020

This may be fixed in atom-languageclient v1.0.0 if it is not please open an issue on the new repo https://github.com/atom-ide-community/atom-languageclient

@machitgarha
Copy link
Collaborator Author

@Gert-dev Could you please release a new version (probably 5.4.1) for this change? Maybe it's late, but I think it was an effective and impactful change.

@Gert-dev
Copy link
Owner

Done - in the spirit of leaving the package in a somewhat stable state (due to #522).

@machitgarha
Copy link
Collaborator Author

machitgarha commented Sep 1, 2021

@Gert-dev Great! Thanks. And yes, the package is in a really good shape (and sorry, I'm personally interested in, but unable to being a maintainer).

@nelson6e65
Copy link

nelson6e65 commented Dec 4, 2021

For $this->myA is successfully autocompleted to $this->myAwesomeMethod(). ✅

But for local variables, it still adds an extra $ as prefix. $thi -> $$this. 🐛

Seems like $ character is not taken in count as prefix, only 'thi' instead of $thi.

@machitgarha
Copy link
Collaborator Author

machitgarha commented Dec 4, 2021

@nelson6e65, as you might already know, that's a separated issue being tracked in #487.

@nelson6e65
Copy link

Oh, sorry. I didn't remember it. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants