+61
osu.Framework.Tests/Visual/UserInterface/TestSceneTextBox.cs
+61
osu.Framework.Tests/Visual/UserInterface/TestSceneTextBox.cs
···
331
331
}
332
332
333
333
[Test]
334
+
public void TestPreviousWordDeletionWithShortWords()
335
+
{
336
+
InsertableTextBox textBox = null;
337
+
338
+
AddStep("add textbox", () =>
339
+
{
340
+
textBoxes.Add(textBox = new InsertableTextBox
341
+
{
342
+
Size = new Vector2(200, 40),
343
+
});
344
+
});
345
+
346
+
AddStep("click on textbox", () =>
347
+
{
348
+
InputManager.MoveMouseTo(textBox);
349
+
InputManager.Click(MouseButton.Left);
350
+
});
351
+
352
+
AddStep("insert three words", () => textBox.InsertString("a b c"));
353
+
AddStep("delete last word", () => InputManager.Keys(PlatformAction.DeleteBackwardWord));
354
+
AddAssert("two words remain", () => textBox.Text == "a b ");
355
+
AddStep("delete last word", () => InputManager.Keys(PlatformAction.DeleteBackwardWord));
356
+
AddAssert("one word remains", () => textBox.Text == "a ");
357
+
AddStep("delete last word", () => InputManager.Keys(PlatformAction.DeleteBackwardWord));
358
+
AddAssert("text is empty", () => textBox.Text.Length == 0);
359
+
AddStep("delete last word", () => InputManager.Keys(PlatformAction.DeleteBackwardWord));
360
+
AddAssert("text is empty", () => textBox.Text.Length == 0);
361
+
}
362
+
363
+
[Test]
334
364
public void TestNextWordDeletion()
335
365
{
336
366
InsertableTextBox textBox = null;
···
355
385
AddAssert("two words remain", () => textBox.Text == " long text");
356
386
AddStep("delete first word", () => InputManager.Keys(PlatformAction.DeleteForwardWord));
357
387
AddAssert("one word remains", () => textBox.Text == " text");
388
+
AddStep("delete first word", () => InputManager.Keys(PlatformAction.DeleteForwardWord));
389
+
AddAssert("text is empty", () => textBox.Text.Length == 0);
390
+
AddStep("delete first word", () => InputManager.Keys(PlatformAction.DeleteForwardWord));
391
+
AddAssert("text is empty", () => textBox.Text.Length == 0);
392
+
}
393
+
394
+
[Test]
395
+
public void TestNextWordDeletionWithShortWords()
396
+
{
397
+
InsertableTextBox textBox = null;
398
+
399
+
AddStep("add textbox", () =>
400
+
{
401
+
textBoxes.Add(textBox = new InsertableTextBox
402
+
{
403
+
Size = new Vector2(200, 40)
404
+
});
405
+
});
406
+
407
+
AddStep("click on textbox", () =>
408
+
{
409
+
InputManager.MoveMouseTo(textBox);
410
+
InputManager.Click(MouseButton.Left);
411
+
});
412
+
413
+
AddStep("insert three words", () => textBox.InsertString("a b c"));
414
+
AddStep("move caret to start", () => InputManager.Keys(PlatformAction.MoveBackwardLine));
415
+
AddStep("delete first word", () => InputManager.Keys(PlatformAction.DeleteForwardWord));
416
+
AddAssert("two words remain", () => textBox.Text == " b c");
417
+
AddStep("delete first word", () => InputManager.Keys(PlatformAction.DeleteForwardWord));
418
+
AddAssert("one word remains", () => textBox.Text == " c");
358
419
AddStep("delete first word", () => InputManager.Keys(PlatformAction.DeleteForwardWord));
359
420
AddAssert("text is empty", () => textBox.Text.Length == 0);
360
421
AddStep("delete first word", () => InputManager.Keys(PlatformAction.DeleteForwardWord));
+1
-1
osu.Framework/Graphics/UserInterface/TextBox.cs
+1
-1
osu.Framework/Graphics/UserInterface/TextBox.cs
···
288
288
if (!AllowWordNavigation)
289
289
return -1;
290
290
291
-
int searchPrev = Math.Clamp(selectionEnd - 2, 0, Math.Max(0, Text.Length - 1));
291
+
int searchPrev = Math.Clamp(selectionEnd - 1, 0, Math.Max(0, Text.Length - 1));
292
292
while (searchPrev > 0 && text[searchPrev] == ' ')
293
293
searchPrev--;
294
294
int lastSpace = text.LastIndexOf(' ', searchPrev);