@@ -99,6 +99,15 @@ def getJasmineItBlock(phrase, tab):
9999class SublimeConnect ():
100100 context = False
101101
102+ @classmethod
103+ def find_all (self , a_str , sub ):
104+ start = 0
105+ while True :
106+ start = a_str .find (sub , start )
107+ if start == - 1 : return
108+ yield start
109+ start += len (sub ) # use start += 1 to find overlapping matches
110+
102111 @classmethod
103112 def getPageContents (self , cursorLine ):
104113 cursorPosition = cursorLine .begin ()
@@ -108,14 +117,16 @@ def getPageContents(self, cursorLine):
108117 def updateMethodNamePHP (self , edit , cursorLine , methodName , existingMethodResults ):
109118 tab = SublimeConnect .getWhitespaceTab ()
110119 searchExisting = "test" + existingMethodResults # search for current test name
111- methodPosition = self .getPageContents (cursorLine ).find (searchExisting )
112- region = sublime .Region (methodPosition , methodPosition + len (searchExisting ))
113- # debug: self.context.view.add_regions('highlighted_lines', [region] , 'mark', 'dot', sublime.DRAW_OUTLINED)
114-
115- lineToUpdate = self .context .view .line (region )
116- lineContents = self .context .view .substr (lineToUpdate ).strip ().replace (searchExisting , "test" + methodName )
117-
118- self .context .view .replace (edit , lineToUpdate , tab + lineContents )
120+ methodPosition = list (SublimeConnect .find_all (self .getPageContents (cursorLine ), searchExisting ))
121+
122+ for methodPositionCursor in methodPosition :
123+ if (methodPositionCursor >= cursorLine .begin ()):
124+ print (methodPositionCursor , searchExisting , cursorLine .begin ())
125+ region = sublime .Region (methodPositionCursor , methodPositionCursor + len (searchExisting ))
126+ lineToUpdate = self .context .view .line (region )
127+ lineContents = self .context .view .substr (lineToUpdate ).strip ().replace (searchExisting , "test" + methodName )
128+ self .context .view .replace (edit , lineToUpdate , tab + lineContents )
129+ return
119130
120131 @classmethod
121132 def insertMethodName (self , edit , cursorLine , testBlock ):
0 commit comments