Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CSharpMath.Editor.Tests/MathKeyboardTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public void Return(params K[] inputs) =>
T(@"■_5", K.Subscript, K.D5, K.Left, K.Left, K.Backspace, K.X, K.Left, K.Left, K.Left, K.Backspace),
T(@"7+1^X", K.D7, K.Plus, K.D1, K.D2, K.Power, K.X, K.Left, K.Left, K.Backspace),
T(@"7+■^X", K.D7, K.Plus, K.D1, K.Power, K.X, K.Left, K.Left, K.Backspace),
T(@"a(c-2)^3", K.SmallA, K.Power, K.D3, K.Left, K.Left, K.BothRoundBrackets, K.SmallC, K.Minus, K.D2)
]
public void LeftRightBackspace(string latex, params K[] inputs) => Test(latex, inputs);

Expand Down
10 changes: 8 additions & 2 deletions CSharpMath.Editor/Keyboards/MathKeyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,19 @@ void InsertParens() {
MathList.InsertAndAdvance(ref _insertionIndex, MathAtoms.ForCharacter('('), MathListSubIndexType.None);
MathList.InsertAndAdvance(ref _insertionIndex, MathAtoms.ForCharacter(')'), MathListSubIndexType.None);
// Don't go to the next insertion index, to start inserting before the close parens.
_insertionIndex = _insertionIndex.Previous;
if (_insertionIndex.FinalSubIndexType is MathListSubIndexType.BetweenBaseAndScripts)
_insertionIndex = _insertionIndex.LevelDown();
else
_insertionIndex = _insertionIndex.Previous;
}
void InsertAbsValue() {
MathList.InsertAndAdvance(ref _insertionIndex, MathAtoms.ForCharacter('|'), MathListSubIndexType.None);
MathList.InsertAndAdvance(ref _insertionIndex, MathAtoms.ForCharacter('|'), MathListSubIndexType.None);
// Don't go to the next insertion index, to start inserting before the close parens.
_insertionIndex = _insertionIndex.Previous;
if (_insertionIndex.FinalSubIndexType is MathListSubIndexType.BetweenBaseAndScripts)
_insertionIndex = _insertionIndex.LevelDown();
else
_insertionIndex = _insertionIndex.Previous;
}

void MoveCursorLeft() {
Expand Down