From d088f1d241ee759647542f212fb1bcfd81af7c4d Mon Sep 17 00:00:00 2001 From: Ionut Staicu Date: Mon, 13 Jul 2015 13:15:22 +0300 Subject: [PATCH] A bit smarter cursor position (DRY version) --- TestNameGenerator.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/TestNameGenerator.py b/TestNameGenerator.py index ce3da1a..576bae1 100644 --- a/TestNameGenerator.py +++ b/TestNameGenerator.py @@ -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): @@ -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):