diff --git a/Main.sublime-menu b/Main.sublime-menu index 76d29fa..26bbf79 100644 --- a/Main.sublime-menu +++ b/Main.sublime-menu @@ -20,7 +20,7 @@ "children": [ { - "caption": "Clear All Python Breakpoints", + "caption": "Clear All PythonBreakpoints", "command": "clear_all_breakpoints", "mnemonic": "C" } @@ -41,13 +41,13 @@ "children": [ { - "caption": "Python Breakpoints", + "caption": "PythonBreakpoints", "children": [ { "caption": "Settings – Default", "command": "open_file", - "args": {"file": "${packages}/Python Breakpoints/PythonBreakpoints.sublime-settings"} + "args": {"file": "${packages}/PythonBreakpoints/PythonBreakpoints.sublime-settings"} }, { "caption": "Settings – User", @@ -59,7 +59,7 @@ "caption": "Key Bindings – Default", "command": "open_file", "args": { - "file": "${packages}/Python Breakpoints/Default (OSX).sublime-keymap", + "file": "${packages}/PythonBreakpoints/Default (OSX).sublime-keymap", "platform": "OSX" } }, @@ -67,7 +67,7 @@ "caption": "Key Bindings – Default", "command": "open_file", "args": { - "file": "${packages}/Python Breakpoints/Default (Linux).sublime-keymap", + "file": "${packages}/PythonBreakpoints/Default (Linux).sublime-keymap", "platform": "Linux" } }, @@ -75,7 +75,7 @@ "caption": "Key Bindings – Default", "command": "open_file", "args": { - "file": "${packages}/Python Breakpoints/Default (Windows).sublime-keymap", + "file": "${packages}/PythonBreakpoints/Default (Windows).sublime-keymap", "platform": "Windows" } }, diff --git a/PythonBreakpoints.py b/PythonBreakpoints.py index 048fa73..49e0a63 100644 --- a/PythonBreakpoints.py +++ b/PythonBreakpoints.py @@ -46,8 +46,8 @@ def plugin_loaded(): # Constants # ############# -bp_regex = r"^[\t ]*import [\w.; ]+set_trace\(\) # breakpoint ([a-f0-9]{8})([a-z]?) //" -bp_re = re.compile(bp_regex, re.DOTALL) +bp_regex = r"^[\t ].*# breakpoint ([a-f0-9]{8})([a-z]?) //" +bp_re = re.compile(bp_regex, re.DOTALL) EXPR_PRE = ['class', 'def', 'if', 'for', 'try', 'while', 'with'] EXPR_PST = ['elif', 'else', 'except', 'finally'] @@ -86,9 +86,10 @@ def as_string(self, indent): """ format breakpoint string """ - debugger = settings.get('debugger', 'pdb') - return "{indent}import {dbg}; {dbg}.set_trace() # breakpoint {uid}{mark} //\n".format( - indent=' ' * indent, dbg=debugger, uid=self.uid, mark='x' if self.in_block else '') + custom_string = settings.get('breakpoint_string', 'import pdb; pdb.set_trace()') + return "{indent}{breakpoint_string} # breakpoint {uid}{mark} //\n".format( + indent=' ' * indent, breakpoint_string=custom_string, + uid=self.uid, mark='x' if self.in_block else '') def highlight(self, view, rg): """ diff --git a/PythonBreakpoints.sublime-settings b/PythonBreakpoints.sublime-settings index 78ba479..fd39cf9 100644 --- a/PythonBreakpoints.sublime-settings +++ b/PythonBreakpoints.sublime-settings @@ -1,6 +1,10 @@ { - // preferred debugger (pdb, ipdb, pudb,..) - must support set_trace() call - "debugger": "pdb", + // The string inserted in breakpoint locations. You can use your preferred + // debugger (pdb, ipdb, pudb,..). + // The 'if' statement is to ease conditional breakpoints easier. + // Other examples: + // "if True: import ipdb; ipdb.set_trace(context=10)" + "breakpoint_string": "if True: import pdb; pdb.set_trace()", // "auto" (read from global settings), or a positive integer "tab_size": "auto",