Sublime Forum

Snippets in tabs problem

#1

Current Behavior of Sublimene.

You have a snippet file with two variables in it. You type $1 and when you press tab it applies autocomplete.

what I expect to happen.

You type the variable $1 and when you press tab it should jump to $2.

As you can see in the video, you press tab and autocomplete comes up. you do ctrl+z, and then tab again and it jumps to $2.

https://streamable.com/w3caf0

0 Likes

#2

If you do not want tab to commit the auto-complete you can disable the "tab_completion" setting. Otherwise auto-complete takes priority over snippets, which is generally desired.

0 Likes

#3

The only way to prevent it is to hit escape to cancel the completion panel, atm.

Maybe I am missing something, but I doubt tab_completion to be involved here (in source scope).

tab_completion has no useful effect in source scope with auto_completion: true as in that case snippets are always auto-completed while typing and hitting tab always expands them.

tab_completion makes a difference only in text scope or if auto_completion: false is set. In that case it decides, whether a snippet trigger must perfectly match to expand a snippet via tab, or whether a partly written trigger is completed and than its snippet expanded.

Completion panel is automatically triggered at $1 as it is located after an accessors ->, which is controlled by auto_complete_triggers setting.

I would have expected auto_complete_with_fields: false preventing auto-completion from being triggered within snippet fields, but his setting seems not to have any effect anymore.

Once completion panel is displayed, tab key always runs commit_completion command, regardless any setting being changed. This seems to be required for backwward compatibility reasons with how snippets have been treated in ST3 if the inline tab_completion functionalty was used. It no longer exists, so snippets and completions are both provided by completion panel, which has some edge cases or unexpected side effects.

There’s a "auto_complete_commit_on_tab" setting, which defaults to false and says completions would be committed via enter by default. The description is at least out-dated (or even wrong). The setting actually only disables enter key if set true.

To reproduce:

  1. create a snippet

    <snippet>
        <content><![CDATA[
    Hello->$1 is a ${2:snippet}.
    ]]></content>
        <tabTrigger>hello</tabTrigger>
    </snippet>
    
  2. Create a new view

  3. set syntax to PHP

  4. Add <?php tag

  5. Start typing hell

    <?php
    hell|
    
  6. hit tab

I’d expect "auto_complete_commit_on_tab": false to cause completions to only be committed via enter, but it would effect how snippets are treated.

There are definitely some odds between how snippets and completions and the way the legacy insert_best_completion command has been interpreted in new ST4 completion system - especially in source scopes. Some of them might already have been issued at Github.

0 Likes