Tuesday, January 06, 2009

Vim PHP Debugger Update

My previous post was talking bout how you'd use Vim with plugin as a debugger client for xdebug remote engine. If you already try it, there are some problem you might encounter, especially if you are using Vim 7.x.

The most annoying one is the lack of tab-page editing support, because original plugin is wrote based on vim 6.0 which didn't have tab-page support. when my Vim or gVim (I'm using 7.1) load several tab-page and I start a debugging session, everything still can work as expected as long I didnt change my working tab, but when the session ended, my tab-page goes like hell!. Moreover if I did change my working tab when the debugging session still running and continue tracing the code (by F2, F3, or F4), the window layout just went crazy, this is really a PITA..

below is list of changes I've made to the python script
  • when multiple tab-page loaded, it will remember the initial tab-page which start the debugging session. every debugging command will make sure that you are debugging on that initial tab, so debugging session wont mess other tab.
  • when debugging session ends on multi tab-page window, other tab-page is no longer being duplicated, it will only restore debugging tab
One thing to note, the undo history on the debugging tab would lost, while luckily other tab undo history is retain (even the previous version of plugin would lost all of its undo history), until Bram decided to make Vim able to store its undo history, everytime you want to debug your code just create a new tab and press F5 (or whatever you bind the command to), you can always use other tab to set breakpoint and such.

As I'm learning it, I'm planning to add more common debugging feature to this plugin, please if you find any bug, made a patch, diffs, etc, let me know..

vim plugin update

hope it helps..

6 comments:

Michael Bahnmiller said...

You don't know how long I have been looking for this!!!!!! THANK YOU!!!! I will be trying it imediately! :)

-M

Zeft said...

yeah, ur welcome, if there any bug (especially to the update specification) let me know, thx..

Michael Bahnmiller said...

Hey, I _did_ make the following change around line 141 to debugger.py ...

What it does is opens a new tab when F5 is pressed the first time, so that I don't have to remember to do that. It will also close the opened tab when F6 is pressed. It makes it so that I can keep my Undo History, and also do all debugging in a separate tab.

I also have it re-sourcing my syntax file after F6 is pressed, since my folds look weird after debugging, and I like to keep my special syntax (you can change that line, just thought I would make you aware).

Anyway here it is:
-----------------------------

let s:debuggerRunning = 0
nmap <F5> :call <SID>debuggerFFive()<Cr>
function! s:debuggerFFive()
if s:debuggerRunning
python debugger_run()
else
tabnew
python debugger_run()
let s:debuggerRunning = 1
endif
endfunction

nmap <F6> :call <SID>debuggerFSix()<Cr>
function! s:debuggerFSix()
if s:debuggerRunning
python debugger_quit()
tabclose
let s:debuggerRunning = 0
source ~/.vim/plugin/torte.vim
else
python debugger_quit()
endif
endfunction


"map <F5> :python debugger_run()<Cr>
"map <F6> :python debugger_quit()<r>

-------------------------------------

By the way, if you want to get a hold of me, you can use the contact form on my webpage :)

Thanks,

-M

Zeft said...

yes michael, I've thought about it too, but sometime i dont want another tab created when I start the debug session,

Because, if my gVim windows maximized, and I open a new tab (or by script), my gVim windows suddenly unMaximized leaving the windows size to big for my laptop screen, which make me unable to see the command window, though the problem wouldn't appear if you working with vim in a xterm/terminal, its a bug to gVim i think. But I'm going to put that in the script anyway, commented perhaps, so people can choose whether to use it or not, thx for the tip !

And for the syntax file, I'll take a look, I'm using a default syntax file and didnt notice anything weird.

thank you so much for the info michael!.

Michael Bahnmiller said...

Sure thing :)

And that window max/unmax is kinda weird. Don't know that I've had that happen to me or not before...

I wonder....

_maybe_ you could map <F5> and <F6> one way and maybe <C-F5> and <C-F6> the other way, so that people wouldn't have to comment/uncomment...

just a thought. (I know that I don't like losing undo history for sure!) ... or maybe I could modify the function to prompt the user for which action they would want.... hm.... what do you think?

Anyway, thanks AGAIN for the AWESOME work!!!

-M

Anonymous said...

Awesome! Thank you!