1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00

Merge pull request #14864 from bdach/fix-range-selection-crash-after-keyboard-selection

Fix timeline range selection crashing after non-mouse selection
This commit is contained in:
Dean Herbert 2021-09-28 07:05:00 +09:00 committed by GitHub
commit 4958771fbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View File

@ -223,6 +223,41 @@ namespace osu.Game.Tests.Visual.Editing
moveMouseToObject(() => addedObjects[2]);
AddStep("click first", () => InputManager.Click(MouseButton.Left));
assertSelectionIs(addedObjects.Take(3));
AddStep("release keys", () =>
{
InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.ShiftLeft);
});
}
[Test]
public void TestRangeSelectAfterExternalSelection()
{
var addedObjects = new[]
{
new HitCircle { StartTime = 100 },
new HitCircle { StartTime = 200, Position = new Vector2(100) },
new HitCircle { StartTime = 300, Position = new Vector2(200) },
new HitCircle { StartTime = 400, Position = new Vector2(300) },
};
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
AddStep("select all without mouse", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
assertSelectionIs(addedObjects);
AddStep("hold down shift", () => InputManager.PressKey(Key.ShiftLeft));
moveMouseToObject(() => addedObjects[1]);
AddStep("click second object", () => InputManager.Click(MouseButton.Left));
assertSelectionIs(addedObjects);
moveMouseToObject(() => addedObjects[3]);
AddStep("click fourth object", () => InputManager.Click(MouseButton.Left));
assertSelectionIs(addedObjects.Skip(1));
AddStep("release shift", () => InputManager.ReleaseKey(Key.ShiftLeft));
}
private void assertSelectionIs(IEnumerable<HitObject> hitObjects)

View File

@ -80,7 +80,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
internal override bool MouseDownSelectionRequested(SelectionBlueprint<HitObject> blueprint, MouseButtonEvent e)
{
if (e.ShiftPressed && e.Button == MouseButton.Left && SelectedItems.Any())
if (e.ShiftPressed && e.Button == MouseButton.Left && pivot != null)
{
handleRangeSelection(blueprint, e.ControlPressed);
return true;