Autocomplete/snippets within PHP foreach incorrect


#1

When using autocomplete for a foreach by typing;

foreach<TAB>

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>.


#2

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?


#3

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.


#4

Does it happen if you disable the autocomplete package?


#5

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.


#6

It looks like a variation of this bug:

You might want to add your repro steps onto it.