@@ -61,6 +61,7 @@ class RenderData
61
61
} ;
62
62
private int _initialX ;
63
63
private int _initialY ;
64
+ private bool _waitingToRender ;
64
65
65
66
private ConsoleColor _initialForeground ;
66
67
private ConsoleColor _initialBackground ;
@@ -112,6 +113,7 @@ private void Render()
112
113
_tokens = null ;
113
114
_ast = null ;
114
115
_parseErrors = null ;
116
+ _waitingToRender = true ;
115
117
return ;
116
118
}
117
119
@@ -816,6 +818,7 @@ void UpdateColorsIfNecessary(string newColor)
816
818
// TODO: set WindowTop if necessary
817
819
818
820
_lastRenderTime . Restart ( ) ;
821
+ _waitingToRender = false ;
819
822
}
820
823
821
824
private static string Spaces ( int cnt )
@@ -980,37 +983,44 @@ private void RecomputeInitialCoords()
980
983
981
984
private void MoveCursor ( int newCursor )
982
985
{
983
- // In case the buffer was resized
984
- RecomputeInitialCoords ( ) ;
985
- _previousRender . bufferWidth = _console . BufferWidth ;
986
- _previousRender . bufferHeight = _console . BufferHeight ;
987
-
988
- var point = ConvertOffsetToPoint ( newCursor ) ;
989
- if ( point . Y < 0 )
986
+ // Only update screen cursor if the buffer is fully rendered.
987
+ if ( ! _waitingToRender )
990
988
{
991
- Ding ( ) ;
992
- return ;
993
- }
989
+ // In case the buffer was resized
990
+ RecomputeInitialCoords ( ) ;
991
+ _previousRender . bufferWidth = _console . BufferWidth ;
992
+ _previousRender . bufferHeight = _console . BufferHeight ;
994
993
995
- if ( point . Y == _console . BufferHeight )
996
- {
997
- // The cursor top exceeds the buffer height, so adjust the initial cursor
998
- // position and the to-be-set cursor position for scrolling up the buffer.
999
- _initialY -= 1 ;
1000
- point . Y -= 1 ;
994
+ var point = ConvertOffsetToPoint ( newCursor ) ;
995
+ if ( point . Y < 0 )
996
+ {
997
+ Ding ( ) ;
998
+ return ;
999
+ }
1001
1000
1002
- // Insure the cursor is on the last line of the buffer prior
1003
- // to issuing a newline to scroll the buffer.
1004
- _console . SetCursorPosition ( point . X , point . Y ) ;
1001
+ if ( point . Y == _console . BufferHeight )
1002
+ {
1003
+ // The cursor top exceeds the buffer height, so adjust the initial cursor
1004
+ // position and the to-be-set cursor position for scrolling up the buffer.
1005
+ _initialY -= 1 ;
1006
+ point . Y -= 1 ;
1005
1007
1006
- // Scroll up the buffer by 1 line.
1007
- _console . Write ( "\n " ) ;
1008
- }
1009
- else
1010
- {
1011
- _console . SetCursorPosition ( point . X , point . Y ) ;
1008
+ // Insure the cursor is on the last line of the buffer prior
1009
+ // to issuing a newline to scroll the buffer.
1010
+ _console . SetCursorPosition ( point . X , point . Y ) ;
1011
+
1012
+ // Scroll up the buffer by 1 line.
1013
+ _console . Write ( "\n " ) ;
1014
+ }
1015
+ else
1016
+ {
1017
+ _console . SetCursorPosition ( point . X , point . Y ) ;
1018
+ }
1012
1019
}
1013
1020
1021
+ // While waiting to render, and a keybinding has occured that is moving the cursor,
1022
+ // converting offset to point could potentially result in an invalid screen position,
1023
+ // but the insertion point should reflect the move.
1014
1024
_current = newCursor ;
1015
1025
}
1016
1026
0 commit comments