Sublime Forum

Debugging PHP snippet

#1

I’m writing some PHP and the top snippet suggestion here is --totp which I’ve no idea where that’s come from, is there a way for me to delete this snippet, In this context when I press tab what I want to happen is that the current line is indented

I don’t want this:

0 Likes

#2

As it says - totp comes from test.php in the autocomplete… Just look for it in test.php to see where it’s defined…

As for the snippet - show us your code so we know what we’re dealing with - if it isn’t a snippet question it may be an autocomplete question ( which is what it currently looks like )…

AutoComplete data is populated from project files so somewhere you have that partial phrase entered… Or it could be interpreted incorrectly by the autocomplete system… We need more information.

Here are some of my snippets which may help you answer your snippet question - these are for GLua

<!--

GM:AcceptInput( [Entity] _ent, [String] _input, [Entity] _activator, [Entity] _caller, [Any] _data )

Called when a map I/O event occurs.

Realm:
	Server only

Arg: _ent
	Entity that receives the input - func_button, for instance, returned as an Entity...

Arg: _input
	The input name

Arg: _activator
	Activator of the input - can be the same as caller

Arg: _caller
	Caller of the input - typically a Player...

Arg: _data
		Data provided with the input

Return: Boolean
	Blocks the input the entity would receive when using true - with false the result is unknown...

 -->
<snippet>
	<content><![CDATA[//
// [ SERVER ] GM:AcceptInput( <Entity> _ent, <String> _input, <Entity> _activator, <Entity> _caller, <Any> _data ) Hook - Called when a map I/O event occurs. - ${1:Description}
//
hook.Add( "AcceptInput", "${2:UNIQUE_ID}", function( _ent, _input, _activator, _p, _data )
	${4:--// Hook Contents}
end );
${5:}]]></content>
	<tabTrigger>hook.Add AcceptInput</tabTrigger>
	<scope>source.lua</scope>
	<description>Creates: GM:AcceptInput( [Entity] _ent, [String] _input, [Entity] _activator, [Entity] _caller, [Any] _data ) Hook</description>
</snippet>
<!--


 -->
<snippet>
    <content><![CDATA[//
// ${1:Description}
//
function Acecool.C.${2:SYSTEM}:${3:FUNC_NAME}( ${4:ARGUMENTS} )
	${5:--// Contents}
end );
${6:}]]></content>
    <tabTrigger>funcs</tabTrigger>
    <scope>source.lua</scope>
    <description>Creates: function acecool.C.SYSTEM:NAME( ARGS ); - 3 comment lines precedes data</description>
</snippet>
<!--


 -->
<snippet>
    <content><![CDATA[//
// ${1:Description}
//
acecool.C.networking:AddReceiver( "${2:ReceiverName}", function( _p, ${3:ARGUMENTS} )
	${4:--// Contents}
end );
${4:}]]></content>
    <tabTrigger>networking:AddReceiver</tabTrigger>
    <scope>source.lua</scope>
    <description>Creates: acecool.C.networking:AddReceiver( "COMMAND", function( _p _cmd, _args, _args_text ) ... end ); - 3 comment lines precedes concommand.Add</description>
</snippet>
0 Likes

#3

You’re right --totp does exist in test.php, the problem isn’t so much that the auto complete is wrong, the problem is that I’m intending for tab in this context to indent code right rather than trigger auto compete

0 Likes

#4

When you add a field - it appears as: $(number:DEFAULT CONTENTS)

if you want the contents to be indented by default, you can either add the tab within the default contents segment ( in which case when you cycle through the replaceable elements, that tab and all data will be highlighted to be replaced ), or you can put the tab before the data…

If you see my example, the reason I don’t indent the 3 lines starting with // at the beginning to match the indentation of <content… is because those tabs would appear in the output… As it stands, I can add a quick description, give it a unique id, and give it code - for some reason I skipped 3… but $4 is tabbed so that code will be tabbed and the highlighted code which can be replaced when I start typing is --// Hook Contents

---- more…

When a snippet is used, as far as I know - and there may be a way to change the behavior - tab will cycle to the next replaceable element… I personally have the options / settings configured to use tab instead of space, or enter because I kept having issues with enter causing auto-complete to finish something which I didn’t want finish… Now, I have the issue where when I press tab while trying to align code, it’ll auto-complete some of the time…

Here are my current settings regarding auto-complete:

	"auto_complete_commit_on_tab": true,
	"auto_complete_cycle": true,
	"auto_complete_delay": 0,
	"auto_complete_selector": "meta.tag - punctuation.definition.tag.begin, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
	"auto_complete_triggers":
	[
		{
			"characters": "<",
			"selector": "text.html"
		}
	],
	"auto_complete_with_fields": true,
	"auto_match_enabled": false,

it’s likely the commit on tab, cycle and with fields options may be influencing the options… If they aren’t responsible then it may be another I’m not aware of… Hopefully this helps…

I keep getting 500 error on post which is why this response has taken a lot of time…

I keep getting 500 error on post which is why this response has taken a lot of time…

0 Likes