Sublime Forum

PHP loops/conditionals autocomplete in HTML broken

#1

I just upgraded to ST4 from ST3 and am experiencing issues with autocompletion for in-HTML loops and conditionals that should appear like this:

<?php foreach ($collection as $item): ?>
      <!-- HTML here -->
<?php endforeach ?>

Previously, typing either foreach or if and hitting tab would autocomplete to this. In ST4 typing if autocompletes to < iframe > and foreach does not autocomplete unless it exists elsewhere in the file and it expands as a string.

The file has a .php extension and the language is set to PHP. I disabled several packages to check for conflict although I am using the same set of packages that I used in ST3 and I never had these issues there. It seems like ST4 is treating a PHP file with HTML in it as an HTML document.

Defs slowing me down a lot, any insights?

0 Likes

#2

Does it happen in SAFE MODE? Asking, because it completes the way you want it for me here.

You may want to check your key bindings because some commands such as insert_best_completion have been removed. So you might need to tweak those slightly.

0 Likes

#3

It does work in safe mode.

For regular mode I’ve disabled every package installed, removed every snippet created, disabled the two keybindings set (to cycle through tabs in order) and restarted. Still no dice. I’m not familiar with the insert_best_completion keybinding and other than the tab cycling have not configured any other bound keys. Do the keybindings need to be reconfigured to restore the original functionality?

Is there some data or configs persisted somewhere that I’m not aware of?

0 Likes

#4

This was a hard one to diagnose. When I upgraded to ST4 it broke the functionality mentioned above. I attempted to disable packages to diagnose this and that didn’t eliminate the issue.

I uninstalled ST4 and reinstalled, but when I opened ST4 all of my settings and packages were persisted. Uninstalled again and found that Sublime Text removes the program but leaves all of the data in ~/.config/sublime-text (I’m on Linux).

I uninstalled ST4, manually deleted ~/.config/sublime-text, and then reinstalled. Then went back package by package and installed, rebooted, and tested because I wanted all of the packages to load on boot to ensure that it would catch conflicts.

The problem is SublimeCodeIntel. It worked without issue in ST3 but has since broken in ST4. There’s an open issue on the SublimeCodeIntel Git repo that reports some annoying completions happening in Python after ST4 upgrade. The problem is that SCI is applying HTML completions to .php files. Disabling “HTML” and “HTML5” under “codeintel_enabled_languages” in the package configuration fixes this issue. Or you can trash the plugin. Both confirmed solutions.

Hope that helps others who might experience this.

1 Like