diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index afa210a0..de8e9173 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -564,7 +564,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 ) diff --git a/python3/vimspector/disassembly.py b/python3/vimspector/disassembly.py index 101258ed..15d9a2ec 100644 --- a/python3/vimspector/disassembly.py +++ b/python3/vimspector/disassembly.py @@ -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 = [] diff --git a/python3/vimspector/utils.py b/python3/vimspector/utils.py index 57cec0cb..e846d306 100644 --- a/python3/vimspector/utils.py +++ b/python3/vimspector/utils.py @@ -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