Focus active item when pressing tab in buffer search bar (#3859)
Release Notes: - N/A
This commit is contained in:
commit
b348d0e59f
1 changed files with 10 additions and 1 deletions
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
ToggleCaseSensitive, ToggleReplace, ToggleWholeWord,
|
ToggleCaseSensitive, ToggleReplace, ToggleWholeWord,
|
||||||
};
|
};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use editor::{Editor, EditorElement, EditorStyle};
|
use editor::{Editor, EditorElement, EditorStyle, Tab};
|
||||||
use futures::channel::oneshot;
|
use futures::channel::oneshot;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, impl_actions, Action, AppContext, ClickEvent, EventEmitter, FocusableView,
|
actions, div, impl_actions, Action, AppContext, ClickEvent, EventEmitter, FocusableView,
|
||||||
|
@ -190,6 +190,7 @@ impl Render for BufferSearchBar {
|
||||||
.w_full()
|
.w_full()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.key_context(key_context)
|
.key_context(key_context)
|
||||||
|
.capture_action(cx.listener(Self::tab))
|
||||||
.on_action(cx.listener(Self::previous_history_query))
|
.on_action(cx.listener(Self::previous_history_query))
|
||||||
.on_action(cx.listener(Self::next_history_query))
|
.on_action(cx.listener(Self::next_history_query))
|
||||||
.on_action(cx.listener(Self::dismiss))
|
.on_action(cx.listener(Self::dismiss))
|
||||||
|
@ -932,6 +933,14 @@ impl BufferSearchBar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tab(&mut self, _: &Tab, cx: &mut ViewContext<Self>) {
|
||||||
|
if let Some(item) = self.active_searchable_item.as_ref() {
|
||||||
|
let focus_handle = item.focus_handle(cx);
|
||||||
|
cx.focus(&focus_handle);
|
||||||
|
cx.stop_propagation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn next_history_query(&mut self, _: &NextHistoryQuery, cx: &mut ViewContext<Self>) {
|
fn next_history_query(&mut self, _: &NextHistoryQuery, cx: &mut ViewContext<Self>) {
|
||||||
if let Some(new_query) = self.search_history.next().map(str::to_string) {
|
if let Some(new_query) = self.search_history.next().map(str::to_string) {
|
||||||
let _ = self.search(&new_query, Some(self.search_options), cx);
|
let _ = self.search(&new_query, Some(self.search_options), cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue