Skip to content

Commit 4e5bf1c

Browse files
committed
Remove SetBufferState
SetBufferState doesn't support Undo/Redo. I want to encourage handlers to always support undo, so it's best to remove a code path that can't easily support undo.
1 parent 9be92ea commit 4e5bf1c

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

PSReadLine/ReadLine.cs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,12 +2436,18 @@ public static void SetKeyHandler(string[] key, Action<ConsoleKeyInfo?, object> h
24362436
}
24372437
}
24382438

2439+
/// <summary>
2440+
/// Get the state of the buffer - the current input and the position of the cursor
2441+
/// </summary>
24392442
public static void GetBufferState(out string input, out int cursor)
24402443
{
24412444
input = _singleton._buffer.ToString();
24422445
cursor = _singleton._current;
24432446
}
24442447

2448+
/// <summary>
2449+
/// Get the state of the buffer - the ast, tokens, errors, and position of the cursor
2450+
/// </summary>
24452451
public static void GetBufferState(out Ast ast, out Token[] tokens, out ParseError[] parseErrors, out int cursor)
24462452
{
24472453
_singleton.ParseInput();
@@ -2475,27 +2481,6 @@ public static void SetCursorPosition(int cursor)
24752481
_singleton._current = cursor;
24762482
_singleton.PlaceCursor();
24772483
}
2478-
2479-
/// <summary>
2480-
/// Set the text in the buffer and the position of the cursor.
2481-
/// </summary>
2482-
public static void SetBufferState(string input, int cursor)
2483-
{
2484-
if (input == null)
2485-
return;
2486-
2487-
EnsureIsInitialized();
2488-
2489-
if (cursor > input.Length)
2490-
cursor = input.Length;
2491-
if (cursor < 0)
2492-
cursor = 0;
2493-
2494-
_singleton._buffer.Clear();
2495-
_singleton._buffer.Append(input);
2496-
_singleton._current = cursor;
2497-
_singleton.Render();
2498-
}
24992484
}
25002485

25012486
internal class ConsoleKeyInfoComparer : IEqualityComparer<ConsoleKeyInfo>

0 commit comments

Comments
 (0)