Tidy up the buffer append logic

Vim seems to insist that a buffer has at least one line. This means that
the first line set in the buffer object has to be a special case. Sigh.
Create a method to wrap that up.
This commit is contained in:
Ben Jackson 2018-06-03 17:16:20 +01:00
commit df10cd84cf
4 changed files with 46 additions and 19 deletions

View file

@ -32,7 +32,8 @@ class OutputView( object ):
self._CreateBuffer( category )
with utils.ModifiableScratchBuffer( self._buffers[ category ] ):
self._buffers[ category ].append( event[ 'output' ].splitlines() )
utils.AppendToBuffer( self._buffers[ category ],
event[ 'output' ].splitlines() )
def Reset( self ):
self.Clear()
@ -54,7 +55,8 @@ class OutputView( object ):
with utils.RestoreCurrentBuffer( self._window ):
vim.command( 'enew' )
self._buffers[ category ] = vim.current.buffer
self._buffers[ category ].append( category + '-----' )
utils.AppendToBuffer( self._buffers[ category ],
category + '-----' )
utils.SetUpHiddenBuffer( self._buffers[ category ],
'vimspector.Output:{0}'.format( category ) )