Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bit smarter cursor position (DRY version) #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion TestNameGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ def run(self, edit):

if existingMethod == False:
SublimeConnect.insertMethodName(edit, cursorLine, TextHelper.prepareTestBlockPHP(phrase, methodName))
TextHelper.closingSnippet(self.view)
else:
SublimeConnect.updateMethodNamePHP(edit, cursorLine, methodName, existingMethod)

else:
# JS will add a new test method because the text is inside the test method
SublimeConnect.insertMethodName(edit, cursorLine, TextHelper.prepareTestBlockJS(phrase))
TextHelper.closingSnippet(self.view)

class TextHelper():
def patternExistingMethodPHP(lineContents):
Expand All @@ -73,7 +75,11 @@ def patternMethodName():

def prepareTestBlockPHP(phrase, methodName):
tab = SublimeConnect.getWhitespaceTab()
return tab + "/**\n" + tab + " * " + phrase + "\n" + tab + " */\n" + tab + "public function test" + methodName + "()\n" + tab + "{\n\n" + tab + "}\n\n" + tab
return tab + "/**\n" + tab + " * " + phrase + "\n" + tab + " */\n" + tab + "public function test" + methodName + "()"

def closingSnippet(view):
view.run_command("insert_snippet", {"contents": "\n\{\n\t$5\n\}"})


# will generate Jasmine blocks
def prepareTestBlockJS(phrase):
Expand Down