@@ -397,7 +397,21 @@ def trg_from_pos(self, buf, pos, implicit=True, DEBUG=False, ac=None):
397397 # fourth_char, fourth_style = last_four_char_and_styles[3]
398398 if prev_style == last_style :
399399 trig_pos , ch , style = ac .getPrevPosCharStyle ()
400- if style == last_style :
400+
401+ if buf .accessor .char_at_pos (pos - 2 ) == '_' and buf .accessor .char_at_pos (pos - 3 ) == '_' and buf .accessor .style_at_pos (pos - 4 ) == self .whitespace_style :
402+ # XXX - Check the php version, magic methods only
403+ # appeared in php 5.
404+ #
405+ p , ch , style = ac .getPrevPosCharStyle (ignore_styles = self .comment_styles )
406+ last_keyword = ac .getTextBackWithStyle (self .keyword_style , max_text_len = 9 )[1 ].strip ()
407+ if last_keyword == "function" :
408+ if DEBUG :
409+ print "triggered:: complete magic-methods"
410+ return Trigger (
411+ lang , TRG_FORM_CPLN , "magic-methods" ,
412+ prev_pos , implicit )
413+
414+ elif style == last_style :
401415 p , ch , style = ac .getPrevPosCharStyle (
402416 ignore_styles = self .comment_styles )
403417 # style is None if no change of style (not ignored) was
@@ -448,19 +462,6 @@ def trg_from_pos(self, buf, pos, implicit=True, DEBUG=False, ac=None):
448462 print "identifier preceeded by an invalid style: " \
449463 "%r, p: %r" % (style , p , )
450464
451- elif last_char == '_' and prev_char == '_' and \
452- style == self .whitespace_style :
453- # XXX - Check the php version, magic methods only
454- # appeared in php 5.
455- p , ch , style = ac .getPrevPosCharStyle (
456- ignore_styles = self .comment_styles )
457- if style == self .keyword_style and \
458- ac .getTextBackWithStyle (style , max_text_len = 9 )[1 ] == "function" :
459- if DEBUG :
460- print "triggered:: complete magic-methods"
461- return Trigger (
462- lang , TRG_FORM_CPLN , "magic-methods" ,
463- prev_pos , implicit )
464465
465466 # PHPDoc completions
466467 elif last_char == "@" and last_style in self .comment_styles :
0 commit comments