-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand selection to whole word when pressing *
#6046
base: master
Are you sure you want to change the base?
Changes from all commits
428c5c7
b917595
fa552f1
109ede2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,56 @@ async fn test_goto_file_impl() -> anyhow::Result<()> { | |
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn test_search_selection() -> anyhow::Result<()> { | ||
// Single selection with a length of 1: search for the whole word | ||
test_key_sequence( | ||
&mut helpers::AppBuilder::new().build()?, | ||
Some("ifoobar::baz<esc>3bl*"), // 3b places the cursor on the first letter of 'foobar', then move one to the right for good measure | ||
Some(&|app| { | ||
assert!( | ||
r#"register '/' set to 'foobar'"# == app.editor.get_status().unwrap().0 | ||
&& Some(&"foobar".to_string()) == app.editor.registers.first('/') | ||
); | ||
}), | ||
false, | ||
) | ||
.await?; | ||
|
||
// Single selection with a length greather than 1: only search for the selection | ||
test_key_sequence( | ||
&mut helpers::AppBuilder::new().build()?, | ||
Some("ifoobar::baz<esc>3blvll*"), // 3b places the cursor on the first letter of 'foobar', then move one to the right for good measure, then select two more chars for a total of three | ||
Some(&|app| { | ||
assert!( | ||
r#"register '/' set to 'oob'"# == app.editor.get_status().unwrap().0 | ||
&& Some(&"oob".to_string()) == app.editor.registers.first('/') | ||
); | ||
}), | ||
false, | ||
) | ||
.await?; | ||
|
||
// Multiple selection of length 1 each : should still only search for the selection | ||
test_key_sequence( | ||
&mut helpers::AppBuilder::new().build()?, | ||
Some("ifoobar::baz<ret>bar::crux<esc>k3blC*"), // k3b places the cursor on the first letter of 'foobar', then move one to the right for good measure, then adds a cursor on the line below | ||
Some(&|app| { | ||
assert!( | ||
// The selections don't seem to be ordered, so we have to test for the two possible orders. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe what's happening here is that collecting into a hashmap might change the order. The selections do have a deterministic order There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The source code could add the |
||
(r#"register '/' set to 'o|a'"# == app.editor.get_status().unwrap().0 | ||
|| r#"register '/' set to 'a|o'"# == app.editor.get_status().unwrap().0) | ||
&& (Some(&"o|a".to_string()) == app.editor.registers.first('/') | ||
|| Some(&"a|o".to_string()) == app.editor.registers.first('/')) | ||
); | ||
}), | ||
false, | ||
) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn test_multi_selection_paste() -> anyhow::Result<()> { | ||
test(( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing
false
here makes this look for the surrounding "word" rather than the "WORD". I think that's an ok behavior but the change inbook/src/keymap.md
should mentionmiw
instead ofmiW
. Also seehelix/helix-term/src/commands.rs
Lines 5000 to 5001 in d570c29