Work around vim bugs in appending to buffers
This commit is contained in:
parent
0cfe1ec99b
commit
cbff48c959
1 changed files with 24 additions and 14 deletions
|
|
@ -202,6 +202,7 @@ def AskForInput( prompt ):
|
||||||
|
|
||||||
|
|
||||||
def AppendToBuffer( buf, line_or_lines, modified=False ):
|
def AppendToBuffer( buf, line_or_lines, modified=False ):
|
||||||
|
try:
|
||||||
# After clearing the buffer (using buf[:] = None) there is always a single
|
# After clearing the buffer (using buf[:] = None) there is always a single
|
||||||
# empty line in the buffer object and no "is empty" method.
|
# empty line in the buffer object and no "is empty" method.
|
||||||
if len( buf ) > 1 or buf[ 0 ]:
|
if len( buf ) > 1 or buf[ 0 ]:
|
||||||
|
|
@ -213,7 +214,15 @@ def AppendToBuffer( buf, line_or_lines, modified=False ):
|
||||||
else:
|
else:
|
||||||
line = 1
|
line = 1
|
||||||
buf[:] = line_or_lines
|
buf[:] = line_or_lines
|
||||||
|
except vim.error as e:
|
||||||
|
# There seem to be a lot of Vim bugs that lead to E351, whose help says that
|
||||||
|
# this is an internal error. Ignore the error, but write a trace to the log.
|
||||||
|
if 'E315' in str( e ):
|
||||||
|
logging.getLogger( __name__ ).exception(
|
||||||
|
'Internal error while updating buffer' )
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
|
finally:
|
||||||
if not modified:
|
if not modified:
|
||||||
buf.options[ 'modified' ] = False
|
buf.options[ 'modified' ] = False
|
||||||
|
|
||||||
|
|
@ -221,6 +230,7 @@ def AppendToBuffer( buf, line_or_lines, modified=False ):
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ClearBuffer( buf ):
|
def ClearBuffer( buf ):
|
||||||
buf[:] = None
|
buf[:] = None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue