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

@ -93,8 +93,11 @@ class StackTraceView( object ):
for thread in self._threads:
icon = '+' if '_frames' not in thread else '-'
self._buf.append( '{0} Thread: {1}'.format( icon, thread[ 'name' ] ) )
self._line_to_thread[ len( self._buf ) ] = thread
line = utils.AppendToBuffer(
self._buf,
'{0} Thread: {1}'.format( icon, thread[ 'name' ] ) )
self._line_to_thread[ line ] = thread
self._DrawStackTrace( thread )
@ -193,9 +196,10 @@ class StackTraceView( object ):
else:
source = { 'name': '<unknown>' }
self._buf.append(
line = utils.AppendToBuffer(
self._buf,
' {0}: {1}@{2}:{3}'.format( frame[ 'id' ],
frame[ 'name' ],
source[ 'name' ],
frame[ 'line' ] ) )
self._line_to_frame[ len( self._buf ) ] = frame
self._line_to_frame[ line ] = frame