mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-29 10:32:09 +03:00
Focus active item when pressing tab in buffer search bar (#3859)
Release Notes: - N/A
This commit is contained in:
commit
b348d0e59f
@ -7,7 +7,7 @@ use crate::{
|
||||
ToggleCaseSensitive, ToggleReplace, ToggleWholeWord,
|
||||
};
|
||||
use collections::HashMap;
|
||||
use editor::{Editor, EditorElement, EditorStyle};
|
||||
use editor::{Editor, EditorElement, EditorStyle, Tab};
|
||||
use futures::channel::oneshot;
|
||||
use gpui::{
|
||||
actions, div, impl_actions, Action, AppContext, ClickEvent, EventEmitter, FocusableView,
|
||||
@ -190,6 +190,7 @@ impl Render for BufferSearchBar {
|
||||
.w_full()
|
||||
.gap_2()
|
||||
.key_context(key_context)
|
||||
.capture_action(cx.listener(Self::tab))
|
||||
.on_action(cx.listener(Self::previous_history_query))
|
||||
.on_action(cx.listener(Self::next_history_query))
|
||||
.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>) {
|
||||
if let Some(new_query) = self.search_history.next().map(str::to_string) {
|
||||
let _ = self.search(&new_query, Some(self.search_options), cx);
|
||||
|
Loading…
Reference in New Issue
Block a user