| ... | ... | @@ -88,7 +88,8 @@ pub enum Command { |
| 88 | 88 | /// Moves the caret a page and the view with it, extending the selection with Shift. |
| 89 | 89 | MovePage { up: bool }, |
| 90 | 90 | /// Moves the selected paragraphs past their sibling above or below: OneNote's Alt+Shift+Up |
| 91 | | /// and Down, Option-Command on macOS as OneNote for Mac binds them. |
| 91 | /// and Down, Option-Command on macOS as OneNote for Mac binds them, and VS Code's Alt or |
| 92 | /// Option with Up and Down. |
| 92 | 93 | MoveParagraphs { up: bool }, |
| 93 | 94 | } |
| 94 | 95 | |
| ... | ... | @@ -289,7 +290,7 @@ fn mac_command(key: &Key, modifiers: Modifiers) -> Option<Command> { |
| 289 | 290 | }; |
| 290 | 291 | match key { |
| 291 | 292 | Key::Named(arrow @ (NamedKey::ArrowUp | NamedKey::ArrowDown)) |
| 292 | | if command && option && !shift && !control => |
| 293 | if option && !shift && !control => |
| 293 | 294 | { |
| 294 | 295 | Some(Command::MoveParagraphs { |
| 295 | 296 | up: *arrow == NamedKey::ArrowUp, |
| ... | ... | @@ -351,14 +352,11 @@ fn mac_command(key: &Key, modifiers: Modifiers) -> Option<Command> { |
| 351 | 352 | /// and End reaches the document's ends; Control with Up and Down moves by paragraphs. |
| 352 | 353 | fn pc_command(key: &Key, modifiers: Modifiers) -> Option<Command> { |
| 353 | 354 | let Modifiers { |
| 354 | | shift, |
| 355 | | control, |
| 356 | | option, |
| 357 | | .. |
| 355 | control, option, .. |
| 358 | 356 | } = modifiers; |
| 359 | 357 | if option { |
| 360 | 358 | return match key { |
| 361 | | _ if !shift || control => None, |
| 359 | _ if control => None, |
| 362 | 360 | Key::Named(NamedKey::ArrowUp) => Some(Command::MoveParagraphs { up: true }), |
| 363 | 361 | Key::Named(NamedKey::ArrowDown) => Some(Command::MoveParagraphs { up: false }), |
| 364 | 362 | _ => None, |
| ... | ... | @@ -605,11 +603,6 @@ mod tests { |
| 605 | 603 | with(|m| (m.command, m.option) = (true, true)), |
| 606 | 604 | Some(Command::Move(Movement::LineEnd)), |
| 607 | 605 | ), |
| 608 | | ( |
| 609 | | named(NamedKey::ArrowUp), |
| 610 | | with(|m| m.option = true), |
| 611 | | Some(Command::Move(Movement::ParagraphStart)), |
| 612 | | ), |
| 613 | 606 | (named(NamedKey::Home), Modifiers::default(), None), |
| 614 | 607 | ( |
| 615 | 608 | named(NamedKey::End), |
| ... | ... | @@ -652,11 +645,36 @@ mod tests { |
| 652 | 645 | with(|m| (m.command, m.option) = (true, true)), |
| 653 | 646 | Some(Command::MoveParagraphs { up: false }), |
| 654 | 647 | ), |
| 648 | ( |
| 649 | named(NamedKey::ArrowUp), |
| 650 | with(|m| (m.command, m.option) = (true, true)), |
| 651 | Some(Command::MoveParagraphs { up: true }), |
| 652 | ), |
| 653 | ( |
| 654 | named(NamedKey::ArrowUp), |
| 655 | with(|m| m.option = true), |
| 656 | Some(Command::MoveParagraphs { up: true }), |
| 657 | ), |
| 658 | ( |
| 659 | named(NamedKey::ArrowDown), |
| 660 | with(|m| m.option = true), |
| 661 | Some(Command::MoveParagraphs { up: false }), |
| 662 | ), |
| 655 | 663 | ( |
| 656 | 664 | named(NamedKey::ArrowUp), |
| 657 | 665 | with(|m| (m.shift, m.option) = (true, true)), |
| 658 | 666 | Some(Command::Move(Movement::ParagraphStart)), |
| 659 | 667 | ), |
| 668 | ( |
| 669 | named(NamedKey::ArrowDown), |
| 670 | with(|m| (m.shift, m.option) = (true, true)), |
| 671 | Some(Command::Move(Movement::ParagraphEnd)), |
| 672 | ), |
| 673 | ( |
| 674 | named(NamedKey::ArrowUp), |
| 675 | with(|m| (m.control, m.option) = (true, true)), |
| 676 | Some(Command::Move(Movement::ParagraphStart)), |
| 677 | ), |
| 660 | 678 | ]; |
| 661 | 679 | for (key, modifiers, command) in cases { |
| 662 | 680 | assert_eq!( |
| ... | ... | @@ -688,7 +706,30 @@ mod tests { |
| 688 | 706 | alt_shift, |
| 689 | 707 | Some(Command::MoveParagraphs { up: true }), |
| 690 | 708 | ), |
| 691 | | (named(NamedKey::ArrowUp), alt, None), |
| 709 | ( |
| 710 | named(NamedKey::ArrowDown), |
| 711 | alt_shift, |
| 712 | Some(Command::MoveParagraphs { up: false }), |
| 713 | ), |
| 714 | ( |
| 715 | named(NamedKey::ArrowUp), |
| 716 | alt, |
| 717 | Some(Command::MoveParagraphs { up: true }), |
| 718 | ), |
| 719 | ( |
| 720 | named(NamedKey::ArrowDown), |
| 721 | alt, |
| 722 | Some(Command::MoveParagraphs { up: false }), |
| 723 | ), |
| 724 | ( |
| 725 | named(NamedKey::ArrowUp), |
| 726 | Modifiers { |
| 727 | control: true, |
| 728 | command: true, |
| 729 | ..alt |
| 730 | }, |
| 731 | None, |
| 732 | ), |
| 692 | 733 | ( |
| 693 | 734 | named(NamedKey::ArrowLeft), |
| 694 | 735 | control, |