Autocomplete/snippets within PHP foreach incorrect


When using autocomplete for a foreach by typing;


you get the following

foreach ($variable as $key => $value) {
    # code...

With the $variable highlighted ready for you to type the name of your iterable, then press tab to get to the $key to do the same.

If your Iterable ends with an s, when you press tab you instead get;

foreach ($post<s></s> as $key => $value) {
    # code...

with the cursor in side the <s>HERE</s>.


Can you reproduce this after closing Atom completely and relaunching with atom --safe? I suspect this behavior is caused by a package … perhaps autocomplete-plus?


Yes, same behaviour with --safe, I don’t have that package installed either.

Further to my original post, I have noticed that it isn’t just s on the end that causes this behaviour, but actually any HTML element name at the end (or anywhere) get’s autocompleted.

So potentially the HTML autocompleter is matching within PHP files. Quite feasible I guess, given the nature of PHP in HTML templates.


Does it happen if you disable the autocomplete package?


Yes it still happens. Autocomplete is bound to CTRL+space, this happens on Tab which is Snippets.
if I disable that, then it doesn’t happen, but then of course you get no completion at all.


It looks like a variation of this bug:

You might want to add your repro steps onto it.