2022-08-17 05:28:41 +04:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
|
|
async fn test_move_parent_node_end() -> anyhow::Result<()> {
|
|
|
|
let tests = vec![
|
|
|
|
// single cursor stays single cursor, first goes to end of current
|
|
|
|
// node, then parent
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {r##"
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
"yes"
|
|
|
|
} else {
|
|
|
|
"no#["|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"##},
|
2022-08-17 05:28:41 +04:00
|
|
|
"<A-e>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"#[\n|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
),
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"#[\n|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
"<A-e>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"
|
|
|
|
}#[\n|]#
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
),
|
|
|
|
// select mode extends
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {r##"
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
"yes"
|
|
|
|
} else {
|
|
|
|
#["no"|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"##},
|
2022-08-17 05:28:41 +04:00
|
|
|
"v<A-e><A-e>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
#[\"no\"
|
|
|
|
}\n|]#
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
for test in tests {
|
|
|
|
test_with_config(AppBuilder::new().with_file("foo.rs", None), test).await?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
|
|
async fn test_move_parent_node_start() -> anyhow::Result<()> {
|
|
|
|
let tests = vec![
|
|
|
|
// single cursor stays single cursor, first goes to end of current
|
|
|
|
// node, then parent
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {r##"
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
"yes"
|
|
|
|
} else {
|
|
|
|
"no#["|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"##},
|
2022-08-17 05:28:41 +04:00
|
|
|
"<A-b>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
#[\"|]#no\"
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
),
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"#[\n|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
"<A-b>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else #[{|]#
|
|
|
|
\"no\"
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
),
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else #[{|]#
|
|
|
|
\"no\"
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
"<A-b>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} #[e|]#lse {
|
|
|
|
\"no\"
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
),
|
|
|
|
// select mode extends
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {r##"
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
"yes"
|
|
|
|
} else {
|
|
|
|
#["no"|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"##},
|
2022-08-17 05:28:41 +04:00
|
|
|
"v<A-b><A-b>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else #[|{
|
|
|
|
]#\"no\"
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
),
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {r##"
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
"yes"
|
|
|
|
} else {
|
|
|
|
#["no"|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"##},
|
2022-08-17 05:28:41 +04:00
|
|
|
"v<A-b><A-b><A-b>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-08-17 05:28:41 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} #[|else {
|
|
|
|
]#\"no\"
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-08-17 05:28:41 +04:00
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
for test in tests {
|
|
|
|
test_with_config(AppBuilder::new().with_file("foo.rs", None), test).await?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2022-10-09 02:14:49 +04:00
|
|
|
|
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
|
|
async fn test_smart_tab_move_parent_node_end() -> anyhow::Result<()> {
|
|
|
|
let tests = vec![
|
|
|
|
// single cursor stays single cursor, first goes to end of current
|
|
|
|
// node, then parent
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {r##"
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
"yes"
|
|
|
|
} else {
|
|
|
|
"no#["|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"##},
|
2022-10-09 02:14:49 +04:00
|
|
|
"i<tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"#[|\n]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"#[\n|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
"i<tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"
|
|
|
|
}#[|\n]#
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
// appending to the end of a line should still look at the current
|
|
|
|
// line, not the next one
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no#[\"|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
"a<tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"
|
|
|
|
}#[\n|]#
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
// before cursor is all whitespace, so insert tab
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
#[\"no\"|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
"i<tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
#[|\"no\"]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
// if selection spans multiple lines, it should still only look at the
|
|
|
|
// line on which the head is
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
#[\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
"a<tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"
|
|
|
|
}#[\n|]#
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
#[\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"|]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
"i<tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
#[|\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"]#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
#[l|]#et result = if true {
|
|
|
|
#(\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\"|)#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
"i<tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
#[|l]#et result = if true {
|
|
|
|
#(|\"yes\"
|
|
|
|
} else {
|
|
|
|
\"no\")#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"#[\n|]#
|
|
|
|
} else {
|
|
|
|
\"no\"#(\n|)#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
"i<tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
}#[| ]#else {
|
|
|
|
\"no\"
|
|
|
|
}#(|\n)#
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
#[\"yes\"|]#
|
|
|
|
} else {
|
|
|
|
#(\"no\"|)#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
"i<tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
#[|\"yes\"]#
|
|
|
|
} else {
|
|
|
|
#(|\"no\")#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
// if any cursors are not preceded by all whitespace, then do the
|
|
|
|
// smart_tab action
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
#[\"yes\"\n|]#
|
|
|
|
} else {
|
|
|
|
\"no#(\"\n|)#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
"i<tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
\"yes\"
|
|
|
|
}#[| ]#else {
|
|
|
|
\"no\"
|
|
|
|
}#(|\n)#
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
// Ctrl-tab always inserts a tab
|
|
|
|
(
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
#[\"yes\"\n|]#
|
|
|
|
} else {
|
|
|
|
\"no#(\"\n|)#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
"i<S-tab>",
|
2024-03-31 16:12:17 +04:00
|
|
|
indoc! {"\
|
2022-10-09 02:14:49 +04:00
|
|
|
fn foo() {
|
|
|
|
let result = if true {
|
|
|
|
#[|\"yes\"\n]#
|
|
|
|
} else {
|
|
|
|
\"no #(|\"\n)#
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 16:12:17 +04:00
|
|
|
"},
|
2022-10-09 02:14:49 +04:00
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
for test in tests {
|
|
|
|
test_with_config(AppBuilder::new().with_file("foo.rs", None), test).await?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2023-06-22 08:21:02 +04:00
|
|
|
|
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
|
|
async fn select_all_siblings() -> anyhow::Result<()> {
|
|
|
|
let tests = vec![
|
|
|
|
// basic tests
|
|
|
|
(
|
|
|
|
indoc! {r##"
|
|
|
|
let foo = bar(#[a|]#, b, c);
|
|
|
|
"##},
|
|
|
|
"<A-a>",
|
|
|
|
indoc! {r##"
|
|
|
|
let foo = bar(#[a|]#, #(b|)#, #(c|)#);
|
|
|
|
"##},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
indoc! {r##"
|
|
|
|
let a = [
|
|
|
|
#[1|]#,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
];
|
|
|
|
"##},
|
|
|
|
"<A-a>",
|
|
|
|
indoc! {r##"
|
|
|
|
let a = [
|
|
|
|
#[1|]#,
|
|
|
|
#(2|)#,
|
|
|
|
#(3|)#,
|
|
|
|
#(4|)#,
|
|
|
|
#(5|)#,
|
|
|
|
];
|
|
|
|
"##},
|
|
|
|
),
|
|
|
|
// direction is preserved
|
|
|
|
(
|
|
|
|
indoc! {r##"
|
|
|
|
let a = [
|
|
|
|
#[|1]#,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
];
|
|
|
|
"##},
|
|
|
|
"<A-a>",
|
|
|
|
indoc! {r##"
|
|
|
|
let a = [
|
|
|
|
#[|1]#,
|
|
|
|
#(|2)#,
|
|
|
|
#(|3)#,
|
|
|
|
#(|4)#,
|
|
|
|
#(|5)#,
|
|
|
|
];
|
|
|
|
"##},
|
|
|
|
),
|
|
|
|
// can't pick any more siblings - selection stays the same
|
|
|
|
(
|
|
|
|
indoc! {r##"
|
|
|
|
let a = [
|
|
|
|
#[1|]#,
|
|
|
|
#(2|)#,
|
|
|
|
#(3|)#,
|
|
|
|
#(4|)#,
|
|
|
|
#(5|)#,
|
|
|
|
];
|
|
|
|
"##},
|
|
|
|
"<A-a>",
|
|
|
|
indoc! {r##"
|
|
|
|
let a = [
|
|
|
|
#[1|]#,
|
|
|
|
#(2|)#,
|
|
|
|
#(3|)#,
|
|
|
|
#(4|)#,
|
|
|
|
#(5|)#,
|
|
|
|
];
|
|
|
|
"##},
|
|
|
|
),
|
|
|
|
// each cursor does the sibling select independently
|
|
|
|
(
|
|
|
|
indoc! {r##"
|
|
|
|
let a = [
|
|
|
|
#[1|]#,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
];
|
|
|
|
|
|
|
|
let b = [
|
|
|
|
#("one"|)#,
|
|
|
|
"two",
|
|
|
|
"three",
|
|
|
|
"four",
|
|
|
|
"five",
|
|
|
|
];
|
|
|
|
"##},
|
|
|
|
"<A-a>",
|
|
|
|
indoc! {r##"
|
|
|
|
let a = [
|
|
|
|
#[1|]#,
|
|
|
|
#(2|)#,
|
|
|
|
#(3|)#,
|
|
|
|
#(4|)#,
|
|
|
|
#(5|)#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let b = [
|
|
|
|
#("one"|)#,
|
|
|
|
#("two"|)#,
|
|
|
|
#("three"|)#,
|
|
|
|
#("four"|)#,
|
|
|
|
#("five"|)#,
|
|
|
|
];
|
|
|
|
"##},
|
|
|
|
),
|
|
|
|
// conflicting sibling selections get normalized. Here, the primary
|
|
|
|
// selection would choose every list item, but because the secondary
|
|
|
|
// range covers more than one item, the descendent is the entire list,
|
|
|
|
// which means the sibling is the assignment. The list item ranges just
|
|
|
|
// get normalized out since the list itself becomes selected.
|
|
|
|
(
|
|
|
|
indoc! {r##"
|
|
|
|
let a = [
|
|
|
|
#[1|]#,
|
|
|
|
2,
|
|
|
|
#(3,
|
|
|
|
4|)#,
|
|
|
|
5,
|
|
|
|
];
|
|
|
|
"##},
|
|
|
|
"<A-a>",
|
|
|
|
indoc! {r##"
|
|
|
|
let #(a|)# = #[[
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
]|]#;
|
|
|
|
"##},
|
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
for test in tests {
|
|
|
|
test_with_config(AppBuilder::new().with_file("foo.rs", None), test).await?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2023-06-23 05:33:40 +04:00
|
|
|
|
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
|
|
async fn select_all_children() -> anyhow::Result<()> {
|
|
|
|
let tests = vec![
|
|
|
|
// basic tests
|
|
|
|
(
|
2023-06-25 21:50:37 +04:00
|
|
|
indoc! {r##"
|
2023-06-23 05:33:40 +04:00
|
|
|
let foo = bar#[(a, b, c)|]#;
|
2023-06-25 21:50:37 +04:00
|
|
|
"##},
|
2023-06-23 05:33:40 +04:00
|
|
|
"<A-I>",
|
2023-06-25 21:50:37 +04:00
|
|
|
indoc! {r##"
|
2023-06-23 05:33:40 +04:00
|
|
|
let foo = bar(#[a|]#, #(b|)#, #(c|)#);
|
2023-06-25 21:50:37 +04:00
|
|
|
"##},
|
2023-06-23 05:33:40 +04:00
|
|
|
),
|
|
|
|
(
|
2023-06-25 21:50:37 +04:00
|
|
|
indoc! {r##"
|
2023-06-23 05:33:40 +04:00
|
|
|
let a = #[[
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
]|]#;
|
2023-06-25 21:50:37 +04:00
|
|
|
"##},
|
2023-06-23 05:33:40 +04:00
|
|
|
"<A-I>",
|
2023-06-25 21:50:37 +04:00
|
|
|
indoc! {r##"
|
2023-06-23 05:33:40 +04:00
|
|
|
let a = [
|
|
|
|
#[1|]#,
|
|
|
|
#(2|)#,
|
|
|
|
#(3|)#,
|
|
|
|
#(4|)#,
|
|
|
|
#(5|)#,
|
|
|
|
];
|
2023-06-25 21:50:37 +04:00
|
|
|
"##},
|
2023-06-23 05:33:40 +04:00
|
|
|
),
|
|
|
|
// direction is preserved
|
|
|
|
(
|
2023-06-25 21:50:37 +04:00
|
|
|
indoc! {r##"
|
2023-06-23 05:33:40 +04:00
|
|
|
let a = #[|[
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
]]#;
|
2023-06-25 21:50:37 +04:00
|
|
|
"##},
|
2023-06-23 05:33:40 +04:00
|
|
|
"<A-I>",
|
2023-06-25 21:50:37 +04:00
|
|
|
indoc! {r##"
|
2023-06-23 05:33:40 +04:00
|
|
|
let a = [
|
|
|
|
#[|1]#,
|
|
|
|
#(|2)#,
|
|
|
|
#(|3)#,
|
|
|
|
#(|4)#,
|
|
|
|
#(|5)#,
|
|
|
|
];
|
2023-06-25 21:50:37 +04:00
|
|
|
"##},
|
2023-06-23 05:33:40 +04:00
|
|
|
),
|
|
|
|
// can't pick any more children - selection stays the same
|
|
|
|
(
|
2023-06-25 21:50:37 +04:00
|
|
|
indoc! {r##"
|
2023-06-23 05:33:40 +04:00
|
|
|
let a = [
|
|
|
|
#[1|]#,
|
|
|
|
#(2|)#,
|
|
|
|
#(3|)#,
|
|
|
|
#(4|)#,
|
|
|
|
#(5|)#,
|
|
|
|
];
|
2023-06-25 21:50:37 +04:00
|
|
|
"##},
|
2023-06-23 05:33:40 +04:00
|
|
|
"<A-I>",
|
2023-06-25 21:50:37 +04:00
|
|
|
indoc! {r##"
|
2023-06-23 05:33:40 +04:00
|
|
|
let a = [
|
|
|
|
#[1|]#,
|
|
|
|
#(2|)#,
|
|
|
|
#(3|)#,
|
|
|
|
#(4|)#,
|
|
|
|
#(5|)#,
|
|
|
|
];
|
2023-06-25 21:50:37 +04:00
|
|
|
"##},
|
2023-06-23 05:33:40 +04:00
|
|
|
),
|
|
|
|
// each cursor does the sibling select independently
|
|
|
|
(
|
2023-06-25 21:50:37 +04:00
|
|
|
indoc! {r##"
|
2023-06-23 05:33:40 +04:00
|
|
|
let a = #[|[
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
]]#;
|
|
|
|
|
|
|
|
let b = #([
|
|
|
|
"one",
|
|
|
|
"two",
|
|
|
|
"three",
|
|
|
|
"four",
|
|
|
|
"five",
|
|
|
|
]|)#;
|
2023-06-25 21:50:37 +04:00
|
|
|
"##},
|
2023-06-23 05:33:40 +04:00
|
|
|
"<A-I>",
|
2023-06-25 21:50:37 +04:00
|
|
|
indoc! {r##"
|
2023-06-23 05:33:40 +04:00
|
|
|
let a = [
|
|
|
|
#[|1]#,
|
|
|
|
#(|2)#,
|
|
|
|
#(|3)#,
|
|
|
|
#(|4)#,
|
|
|
|
#(|5)#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let b = [
|
|
|
|
#("one"|)#,
|
|
|
|
#("two"|)#,
|
|
|
|
#("three"|)#,
|
|
|
|
#("four"|)#,
|
|
|
|
#("five"|)#,
|
|
|
|
];
|
2023-06-25 21:50:37 +04:00
|
|
|
"##},
|
2023-06-23 05:33:40 +04:00
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
for test in tests {
|
|
|
|
test_with_config(AppBuilder::new().with_file("foo.rs", None), test).await?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2024-04-23 17:41:03 +04:00
|
|
|
|
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
|
|
async fn test_select_next_sibling() -> anyhow::Result<()> {
|
|
|
|
let tests = vec![
|
|
|
|
// basic test
|
|
|
|
(
|
|
|
|
indoc! {r##"
|
|
|
|
fn inc(x: usize) -> usize { x + 1 #[}|]#
|
|
|
|
fn dec(x: usize) -> usize { x - 1 }
|
|
|
|
fn ident(x: usize) -> usize { x }
|
|
|
|
"##},
|
|
|
|
"<A-n>",
|
|
|
|
indoc! {r##"
|
|
|
|
fn inc(x: usize) -> usize { x + 1 }
|
|
|
|
#[fn dec(x: usize) -> usize { x - 1 }|]#
|
|
|
|
fn ident(x: usize) -> usize { x }
|
|
|
|
"##},
|
|
|
|
),
|
|
|
|
// direction is not preserved and is always forward.
|
|
|
|
(
|
|
|
|
indoc! {r##"
|
|
|
|
fn inc(x: usize) -> usize { x + 1 #[}|]#
|
|
|
|
fn dec(x: usize) -> usize { x - 1 }
|
|
|
|
fn ident(x: usize) -> usize { x }
|
|
|
|
"##},
|
|
|
|
"<A-n><A-;><A-n>",
|
|
|
|
indoc! {r##"
|
|
|
|
fn inc(x: usize) -> usize { x + 1 }
|
|
|
|
fn dec(x: usize) -> usize { x - 1 }
|
|
|
|
#[fn ident(x: usize) -> usize { x }|]#
|
|
|
|
"##},
|
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
for test in tests {
|
|
|
|
test_with_config(AppBuilder::new().with_file("foo.rs", None), test).await?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
|
|
async fn test_select_prev_sibling() -> anyhow::Result<()> {
|
|
|
|
let tests = vec![
|
|
|
|
// basic test
|
|
|
|
(
|
|
|
|
indoc! {r##"
|
|
|
|
fn inc(x: usize) -> usize { x + 1 }
|
|
|
|
fn dec(x: usize) -> usize { x - 1 }
|
|
|
|
#[|f]#n ident(x: usize) -> usize { x }
|
|
|
|
"##},
|
|
|
|
"<A-p>",
|
|
|
|
indoc! {r##"
|
|
|
|
fn inc(x: usize) -> usize { x + 1 }
|
|
|
|
#[|fn dec(x: usize) -> usize { x - 1 }]#
|
|
|
|
fn ident(x: usize) -> usize { x }
|
|
|
|
"##},
|
|
|
|
),
|
|
|
|
// direction is not preserved and is always backward.
|
|
|
|
(
|
|
|
|
indoc! {r##"
|
|
|
|
fn inc(x: usize) -> usize { x + 1 }
|
|
|
|
fn dec(x: usize) -> usize { x - 1 }
|
|
|
|
#[|f]#n ident(x: usize) -> usize { x }
|
|
|
|
"##},
|
|
|
|
"<A-p><A-;><A-p>",
|
|
|
|
indoc! {r##"
|
|
|
|
#[|fn inc(x: usize) -> usize { x + 1 }]#
|
|
|
|
fn dec(x: usize) -> usize { x - 1 }
|
|
|
|
fn ident(x: usize) -> usize { x }
|
|
|
|
"##},
|
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
for test in tests {
|
|
|
|
test_with_config(AppBuilder::new().with_file("foo.rs", None), test).await?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|