@@ -88,21 +88,18 @@ private string text
88
88
89
89
[ SerializeField ]
90
90
private List < string > inputHistory = new List < string > ( ) ;
91
-
92
- private bool requestMoveToCursorToEnd ;
91
+ private int positionInHistory ;
92
+
93
+ private bool requestMoveCursorToEnd ;
93
94
private bool requestFocusOnTextArea ;
94
-
95
95
private bool requestRevertNewLine ;
96
96
97
97
private string input = "" ;
98
98
private string lastWord = "" ;
99
+ private string savedInput ;
99
100
100
101
private Vector2 lastCursorPos ;
101
102
102
- private int positionInHistory ;
103
-
104
- private string savedInput ;
105
-
106
103
private void Awake ( )
107
104
{
108
105
ClearText ( ) ;
@@ -142,14 +139,14 @@ private void OnInspectorUpdate()
142
139
143
140
private void OnGUI ( )
144
141
{
145
- textEditor = ( TextEditor ) GUIUtility . GetStateObject ( typeof ( TextEditor ) , GUIUtility . keyboardControl ) ;
142
+ textEditor = ( TextEditor ) GUIUtility . GetStateObject ( typeof ( TextEditor ) , GUIUtility . keyboardControl ) ;
146
143
if ( text == "" )
147
144
{
148
145
AppendStartCommand ( ) ;
149
146
ScheduleMoveCursorToEnd ( ) ;
150
147
}
151
148
152
- EnsureNotAboutToTypeAtInvalidPosition ( ) ;
149
+ HandleInvalidTypePositions ( ) ;
153
150
autocompleteBox . HandleEvents ( ) ;
154
151
HandleHistory ( ) ;
155
152
DoAutoComplete ( ) ;
@@ -240,10 +237,10 @@ private string GetInput()
240
237
private void HandleRequests ( )
241
238
{
242
239
var current = Event . current ;
243
- if ( requestMoveToCursorToEnd && current . type == EventType . Repaint )
240
+ if ( requestMoveCursorToEnd && current . type == EventType . Repaint )
244
241
{
245
242
textEditor . MoveTextEnd ( ) ;
246
- requestMoveToCursorToEnd = false ;
243
+ requestMoveCursorToEnd = false ;
247
244
Repaint ( ) ;
248
245
}
249
246
else if ( focusedWindow == this && requestFocusOnTextArea )
@@ -266,7 +263,10 @@ private void HandleRequests()
266
263
lastCursorPos = cursorPos ;
267
264
}
268
265
269
- private void EnsureNotAboutToTypeAtInvalidPosition ( )
266
+ /// <summary>
267
+ /// Ensures not about to type at an invalid position.
268
+ /// </summary>
269
+ private void HandleInvalidTypePositions ( )
270
270
{
271
271
var current = Event . current ;
272
272
@@ -278,7 +278,6 @@ private void EnsureNotAboutToTypeAtInvalidPosition()
278
278
if ( current . keyCode == KeyCode . Backspace )
279
279
{
280
280
cursorIndex -- ;
281
-
282
281
}
283
282
284
283
if ( cursorIndex < lastIndexCommand )
@@ -310,6 +309,7 @@ private void DrawAll()
310
309
EditorGUILayout . EndScrollView ( ) ;
311
310
312
311
autocompleteBox . results = shellEvaluator . completions ;
312
+
313
313
var pos = textEditor . graphicalCursorPos ;
314
314
var rect = new Rect ( pos . x , pos . y , 300 , 200 ) ;
315
315
rect . y += 34 ;
@@ -341,6 +341,7 @@ private void DrawConsole()
341
341
}
342
342
343
343
AppendStartCommand ( ) ;
344
+ ScheduleMoveCursorToEnd ( ) ;
344
345
345
346
current . Use ( ) ;
346
347
}
@@ -358,12 +359,11 @@ private void ScrollDown()
358
359
private void AppendStartCommand ( )
359
360
{
360
361
text += CommandName ;
361
- ScheduleMoveCursorToEnd ( ) ;
362
362
}
363
363
364
364
private void ScheduleMoveCursorToEnd ( )
365
365
{
366
- requestMoveToCursorToEnd = true ;
366
+ requestMoveCursorToEnd = true ;
367
367
ScrollDown ( ) ;
368
368
}
369
369
0 commit comments