@@ -1006,7 +1006,6 @@ def _append_custom(self, insert, input, before_prompt=False, *args, **kwargs):
1006
1006
else :
1007
1007
if insert != self ._insert_plain_text :
1008
1008
self ._flush_pending_stream ()
1009
- cursor .movePosition (QtGui .QTextCursor .End )
1010
1009
1011
1010
# Perform the insertion.
1012
1011
result = insert (cursor , input , * args , ** kwargs )
@@ -1660,10 +1659,7 @@ def _on_flush_pending_stream_timer(self):
1660
1659
""" Flush the pending stream output and change the
1661
1660
prompt position appropriately.
1662
1661
"""
1663
- cursor = self ._control .textCursor ()
1664
- cursor .movePosition (QtGui .QTextCursor .End )
1665
1662
self ._flush_pending_stream ()
1666
- cursor .movePosition (QtGui .QTextCursor .End )
1667
1663
1668
1664
def _flush_pending_stream (self ):
1669
1665
""" Flush out pending text into the widget. """
@@ -1674,7 +1670,7 @@ def _flush_pending_stream(self):
1674
1670
text = self ._get_last_lines_from_list (text , buffer_size )
1675
1671
text = '' .join (text )
1676
1672
t = time .time ()
1677
- self ._insert_plain_text (self ._get_end_cursor (), text , flush = True )
1673
+ self ._insert_plain_text (self ._control . textCursor (), text , flush = True )
1678
1674
# Set the flush interval to equal the maximum time to update text.
1679
1675
self ._pending_text_flush_interval .setInterval (
1680
1676
int (max (100 , (time .time () - t ) * 1000 ))
@@ -2123,7 +2119,7 @@ def _insert_plain_text(self, cursor, text, flush=False):
2123
2119
cursor .select (QtGui .QTextCursor .Document )
2124
2120
remove = True
2125
2121
if act .area == 'line' :
2126
- if act .erase_to == 'all' :
2122
+ if act .erase_to == 'all' :
2127
2123
cursor .select (QtGui .QTextCursor .LineUnderCursor )
2128
2124
remove = True
2129
2125
elif act .erase_to == 'start' :
@@ -2137,7 +2133,7 @@ def _insert_plain_text(self, cursor, text, flush=False):
2137
2133
QtGui .QTextCursor .EndOfLine ,
2138
2134
QtGui .QTextCursor .KeepAnchor )
2139
2135
remove = True
2140
- if remove :
2136
+ if remove :
2141
2137
nspace = cursor .selectionEnd ()- cursor .selectionStart () if fill else 0
2142
2138
cursor .removeSelectedText ()
2143
2139
if nspace > 0 : cursor .insertText (' ' * nspace ) # replace text by space, to keep cursor position as specified
@@ -2181,11 +2177,12 @@ def _insert_plain_text(self, cursor, text, flush=False):
2181
2177
remain = cursor2 .position () - pos # number of characters until end of line
2182
2178
n = len (substring )
2183
2179
swallow = min (n , remain ) # number of character to swallow
2184
- cursor .setPosition (pos + swallow ,QtGui .QTextCursor .KeepAnchor )
2180
+ cursor .setPosition (pos + swallow , QtGui .QTextCursor .KeepAnchor )
2185
2181
cursor .insertText (substring ,format )
2186
2182
else :
2187
2183
cursor .insertText (text )
2188
2184
cursor .endEditBlock ()
2185
+ self ._control .setTextCursor (cursor )
2189
2186
2190
2187
if should_autoscroll :
2191
2188
self ._scroll_to_end ()
0 commit comments