vim fixes for find&replace
* allow replacing with the empty string to delete * fix <enter> for ReplaceNext
This commit is contained in:
parent
adf313bd33
commit
2da664ed17
3 changed files with 16 additions and 17 deletions
|
@ -531,7 +531,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "BufferSearchBar > VimEnabled",
|
"context": "BufferSearchBar && !in_replace > VimEnabled",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"enter": "vim::SearchSubmit",
|
"enter": "vim::SearchSubmit",
|
||||||
"escape": "buffer_search::Dismiss"
|
"escape": "buffer_search::Dismiss"
|
||||||
|
|
|
@ -159,7 +159,7 @@ impl SearchQuery {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn with_replacement(mut self, new_replacement: Option<String>) -> Self {
|
pub fn with_replacement(mut self, new_replacement: String) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Self::Text {
|
Self::Text {
|
||||||
ref mut replacement,
|
ref mut replacement,
|
||||||
|
@ -169,7 +169,7 @@ impl SearchQuery {
|
||||||
ref mut replacement,
|
ref mut replacement,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
*replacement = new_replacement;
|
*replacement = Some(new_replacement);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -774,8 +774,7 @@ impl BufferSearchBar {
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
) {
|
) {
|
||||||
Ok(query) => query
|
Ok(query) => query.with_replacement(self.replacement(cx)),
|
||||||
.with_replacement(Some(self.replacement(cx)).filter(|s| !s.is_empty())),
|
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
self.query_contains_error = true;
|
self.query_contains_error = true;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
@ -790,8 +789,7 @@ impl BufferSearchBar {
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
) {
|
) {
|
||||||
Ok(query) => query
|
Ok(query) => query.with_replacement(self.replacement(cx)),
|
||||||
.with_replacement(Some(self.replacement(cx)).filter(|s| !s.is_empty())),
|
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
self.query_contains_error = true;
|
self.query_contains_error = true;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
@ -904,6 +902,9 @@ impl BufferSearchBar {
|
||||||
if let Some(_) = &bar.active_searchable_item {
|
if let Some(_) = &bar.active_searchable_item {
|
||||||
should_propagate = false;
|
should_propagate = false;
|
||||||
bar.replace_is_active = !bar.replace_is_active;
|
bar.replace_is_active = !bar.replace_is_active;
|
||||||
|
if bar.dismissed {
|
||||||
|
bar.show(cx);
|
||||||
|
}
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -921,13 +922,12 @@ impl BufferSearchBar {
|
||||||
.get(&searchable_item.downgrade())
|
.get(&searchable_item.downgrade())
|
||||||
{
|
{
|
||||||
if let Some(active_index) = self.active_match_index {
|
if let Some(active_index) = self.active_match_index {
|
||||||
let query = query.as_ref().clone().with_replacement(
|
let query = query
|
||||||
Some(self.replacement(cx)).filter(|rep| !rep.is_empty()),
|
.as_ref()
|
||||||
);
|
.clone()
|
||||||
|
.with_replacement(self.replacement(cx));
|
||||||
searchable_item.replace(&matches[active_index], &query, cx);
|
searchable_item.replace(&matches[active_index], &query, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.focus_editor(&FocusEditor, cx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -941,14 +941,13 @@ impl BufferSearchBar {
|
||||||
.searchable_items_with_matches
|
.searchable_items_with_matches
|
||||||
.get(&searchable_item.downgrade())
|
.get(&searchable_item.downgrade())
|
||||||
{
|
{
|
||||||
let query = query.as_ref().clone().with_replacement(
|
let query = query
|
||||||
Some(self.replacement(cx)).filter(|rep| !rep.is_empty()),
|
.as_ref()
|
||||||
);
|
.clone()
|
||||||
|
.with_replacement(self.replacement(cx));
|
||||||
for m in matches {
|
for m in matches {
|
||||||
searchable_item.replace(m, &query, cx);
|
searchable_item.replace(m, &query, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.focus_editor(&FocusEditor, cx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue