From d7f37776ba8642c6655b040648cc5eb67479b892 2008-06-07 06:50:18 From: vds Date: 2008-06-07 06:50:18 Subject: [PATCH] synchronize with editor patch --- diff --git a/IPython/Debugger.py b/IPython/Debugger.py index 3044e0f..576395c 100644 --- a/IPython/Debugger.py +++ b/IPython/Debugger.py @@ -333,6 +333,12 @@ class Pdb(OldPdb): #frame, lineno = frame_lineno print >>Term.cout, self.format_stack_entry(frame_lineno, '', context) + # vds: >> + frame, lineno = frame_lineno + filename = frame.f_code.co_filename + __IPYTHON__.hooks.synchronize_with_editor(filename, lineno, 0) + # vds: << + def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3): import linecache, repr @@ -496,6 +502,12 @@ class Pdb(OldPdb): last = first + 10 self.print_list_lines(self.curframe.f_code.co_filename, first, last) + # vds: >> + lineno = first + filename = self.curframe.f_code.co_filename + __IPYTHON__.hooks.synchronize_with_editor(filename, lineno, 0) + # vds: << + do_l = do_list def do_pdef(self, arg): diff --git a/IPython/hooks.py b/IPython/hooks.py index 777f308..6a67264 100644 --- a/IPython/hooks.py +++ b/IPython/hooks.py @@ -53,10 +53,12 @@ from pprint import PrettyPrinter # List here all the default hooks. For now it's just the editor functions # but over time we'll move here all the public API for user-accessible things. -__all__ = ['editor', 'fix_error_editor', 'result_display', +# vds: >> +__all__ = ['editor', 'fix_error_editor', 'synchronize_with_editor', 'result_display', 'input_prefilter', 'shutdown_hook', 'late_startup_hook', 'generate_prompt', 'generate_output_prompt','shell_hook', 'show_in_pager','pre_prompt_hook', 'pre_runcode_hook'] +# vds: << pformat = PrettyPrinter().pformat @@ -107,6 +109,10 @@ def fix_error_editor(self,filename,linenum,column,msg): finally: t.close() +# vds: >> +def synchronize_with_editor(self, filename, linenum, column): + pass +# vds: << class CommandChainDispatcher: """ Dispatch calls to a chain of commands until some func can handle it diff --git a/IPython/ultraTB.py b/IPython/ultraTB.py index eb2e579..51a0eee 100644 --- a/IPython/ultraTB.py +++ b/IPython/ultraTB.py @@ -490,6 +490,11 @@ class ListTB(TBTools): Colors.Normal, s)) else: list.append('%s\n' % str(stype)) + + # vds:>> + __IPYTHON__.hooks.synchronize_with_editor(filename, lineno, 0) + # vds:<< + return list def _some_str(self, value): @@ -801,6 +806,15 @@ class VerboseTB(TBTools): for name in names: value = text_repr(getattr(evalue, name)) exception.append('\n%s%s = %s' % (indent, name, value)) + + # vds: >> + if records: + frame, file, lnum, func, lines, index = records[-1] + #print "file:", str(file), "linenb", str(lnum) + file = abspath(file) + __IPYTHON__.hooks.synchronize_with_editor(file, lnum, 0) + # vds: << + # return all our info assembled as a single string return '%s\n\n%s\n%s' % (head,'\n'.join(frames),''.join(exception[0]) )