forked from PowerShell/PSReadLine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUndoRedo.vi.cs
More file actions
66 lines (59 loc) · 1.9 KB
/
Copy pathUndoRedo.vi.cs
File metadata and controls
66 lines (59 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using System;
namespace Microsoft.PowerShell
{
public partial class PSConsoleReadLine
{
private class GroupUndoHelper
{
public Action<ConsoleKeyInfo?, object> _instigator;
public object _instigatorArg;
public GroupUndoHelper()
{
_instigator = null;
_instigatorArg = null;
}
public void StartGroup(Action<ConsoleKeyInfo?, object> instigator, object instigatorArg)
{
_instigator = instigator;
_instigatorArg = instigatorArg;
_singleton.StartEditGroup();
}
public void Clear()
{
_instigator = null;
_instigatorArg = null;
}
public void EndGroup()
{
if (_singleton._editGroupStart >= 0)
{
_singleton.EndEditGroup(_instigator, _instigatorArg);
}
Clear();
}
}
private readonly GroupUndoHelper _groupUndoHelper = new GroupUndoHelper();
/// <summary>
/// Undo all previous edits for line.
/// </summary>
public static void UndoAll(ConsoleKeyInfo? key = null, object arg = null)
{
if (_singleton._undoEditIndex > 0)
{
while (_singleton._undoEditIndex > 0)
{
_singleton._edits[_singleton._undoEditIndex - 1].Undo();
_singleton._undoEditIndex--;
}
_singleton.Render();
}
else
{
Ding();
}
}
}
}