Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wipe out scratch buffers #893

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python3/vimspector/debug_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def SwitchFrom( self ):

def OnChannelData( self, data ):
if self._connection is None:
# Should _not_ happen, but maybe possible due to races or vim bufs?
# Should _not_ happen, but maybe possible due to races or vim bugs?
return

self._connection.OnData( data )
Expand Down
13 changes: 12 additions & 1 deletion python3/vimspector/disassembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,18 @@ def Reset( self ):

self._buf = None
for b in self._scratch_buffers:
utils.CleanUpHiddenBuffer( b )
# FIXME/TODO: Unknown hack :(
# For some reason I can't work out if the buffer is wiped out here, we
# get a test failure in Test_Disassembly_Open_Close.
# Initially I thought it was because _scratch_buffers might contain
# duplicates, but changing it to a set() doesn't help, so it's not that.
# What seems to happen is we get data on the socket/channel and the
# callback tries to do something with the wiped-out buffer.
#
# Unfortunately I can't fathom what's happening, so hacking this
# wipeout=False for now to make the tests pass. Yes, I'll suffer in
# purgatory for that.
utils.CleanUpHiddenBuffer( b, wipeout=False )

self._scratch_buffers = []

Expand Down
9 changes: 5 additions & 4 deletions python3/vimspector/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,16 @@ def CleanUpCommand( session_id, name, api_prefix ):
name ) )


def CleanUpHiddenBuffer( buf ):
def CleanUpHiddenBuffer( buf, wipeout=True ):
if not buf.valid:
return

cmd = 'bwipeout' if wipeout else 'bdelete'

try:
vim.command( 'bdelete! {}'.format( buf.number ) )
vim.command( '{}! {}'.format( cmd, buf.number ) )
except vim.error as e:
# FIXME: For now just ignore the "no buffers were deleted" error
if 'E516' not in str( e ):
if 'E517' not in str( e ) and 'E516' not in str( e ):
raise


Expand Down
Loading