-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoveUp.cs
25 lines (24 loc) · 806 Bytes
/
MoveUp.cs
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
namespace MathKeyboardEngine;
public static class _MoveUp
{
public static void MoveUp(this KeyboardMemory k)
{
var fromPlaceholder = k.Current is Placeholder p ? p : ((TreeNode)k.Current).ParentPlaceholder;
BranchingNode suggestingNode;
while (true)
{
if (fromPlaceholder.ParentNode == null)
{
return;
}
suggestingNode = fromPlaceholder.ParentNode;
var suggestion = suggestingNode.GetMoveUpSuggestion(fromPlaceholder);
if (suggestion != null)
{
k.Current = suggestion.Nodes.LastOrDefault() ?? (SyntaxTreeComponent)suggestion;
return;
}
fromPlaceholder = suggestingNode.ParentPlaceholder;
}
}
}