diff --git a/mavensmate.py b/mavensmate.py index a1d0649..98ed92c 100755 --- a/mavensmate.py +++ b/mavensmate.py @@ -402,7 +402,13 @@ def is_enabled(command): #runs apex unit tests using the async api class RunAsyncApexTestMethodCommand(sublime_plugin.TextCommand): def run(self, edit): - sublime.active_window().show_input_panel("Comma Delimited Test Method Names", "MyTestMethodName", self.finish, None, None) + commaDelimitedTestMethods = "MyTestMethodName" + selectedTests = util.get_selected_texts(); + + if len(selectedTests) != 0: + commaDelimitedTestMethods = ','.join(selectedTests) + + sublime.active_window().show_input_panel("Comma Delimited Test Method Names", commaDelimitedTestMethods, self.finish, None, None) def finish(self, test_method_names): active_file = util.get_active_file() diff --git a/util.py b/util.py index 4fb7871..4f946aa 100644 --- a/util.py +++ b/util.py @@ -588,3 +588,14 @@ def get_version_number(): return version except: return '' + +def get_selected_texts(): + selected = [] + active_view = sublime.active_window().active_view() + + for region in active_view.sel(): + text = active_view.substr(region) + if text != '': + selected.append( text ) + + return selected \ No newline at end of file