brookhong / DBGPavim

This is a plugin to enable php debug in VIM with Xdebug, with a new debug engine.
132 stars 19 forks source link

Undo history lost for all files in VIM tabs upon completing debug session #10

Closed mesamorpho closed 10 years ago

mesamorpho commented 11 years ago

I usually use several VIM tabs holding various files I'm working with. Whenever I complete a debug session, either by letting the program run through (F5) or simply exiting the debugger (F6), the files in all of my tabs are reloaded and as a by-product, my undo history for them is lost.

As a test I did the following:

  1. I opened :e $MyPHPDir/myPHPFile.php, added a line, saved it and set a breakpoint (:Bp).
  2. I then created a new tab with a new file :tabe ~/newFile.htm.
  3. I typed a few lines into ~/someFile.htm and saved it.
  4. I hit (F5) to start the debugger and then loaded up localhost/myPHPFile.php?XDEBUG_SESSION_START=1 in my browser.
  5. When the breakpoint is hit, I pressed (F5) to let the debugger run through and thus finish the debug session.
  6. I switched to the VIM tab holding newFile.htm and hit undo (CTRL-z) and VIM reported that it was at the "Already at oldest change", thus I couldn't undo any of the typing I did just before starting the debugger.
  7. I switched to the VIM tab holding myPHPFile.php and hit undo (CTRL-z) and VIM removed the line I added before starting the debugger.

In this case only the file in the second tab lost its undo history but in my usual working environment (with 49 buffers across 34 tabs) I seem to lose the undo history of all files loaded.

brookhong commented 11 years ago

Thanks for reporting the issue such detail.

Have fixed it, please get the latest version, and try again.

mesamorpho commented 11 years ago

Wow, thanks for fixing this so quickly!!

The tabs are not reloaded anymore when debugging finishes, and the situation I described in my example now works flawlessly. However, in my usual work environment -- with a lot of buffers across several tabs -- the undo history appears to remain intact for all buffers, except for the one in which I set the breakpoint. I have run a few tests in my usual work environment, and sometimes, all buffers seem to have kept their undo history... In other words, for the most part the bug appears to be fixed but on occasion it still occurs for at least one buffer... I've tried to narrow down the exact circumstances but momentarily I don't know how safely reproduce the bug. I'll get back to you if I find a way to reproduce it each time.

mesamorpho commented 11 years ago

Ok, I figured out why VIM sometimes still loses its undo history during debugging. In short, the problem occurs when a file being debugged is open as a split window.

Here's how you can reproduce it:

  1. Launch VIM.
  2. :e $MyPHPDir/myPHPFile.php.
  3. :sp anyOtherFile.
  4. Modify myPHPFile.php and save it.
  5. Set a breakpoint (:Bp) in myPHPFile.php.
  6. Hit F5 to start the debugger and then load up localhost/myPHPFile.php?XDEBUG_SESSION_START=1 in your browser.
  7. When the breakpoint is triggered, the window layout is changed: anyOtherFile is not visible anymore; instead the window is now split between myPHPFile.php, the call stack and watch window.
  8. Pressed F5 to let the debugger run through and thus finish the debug session. The window layout is restored, showing both, myPHPFile.php and anyOtherFile.
  9. Make sure myPHPFile.php has input focus, then hit undo (CTRL-z) and VIM reports that it is "Already at oldest change", thus making it impossible to undo the modification done before starting the debugger.
brookhong commented 10 years ago

This should be fixed completely, as the mksession way to save current vim session is not necessary now. A completely new tab is created to be used debugging UI now.