8000 Prevent tab switching from the command line by ThomasFrans · Pull Request #1176 · hrkfdn/ncspot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Prevent tab switching from the command line #1176

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

Merged
merged 1 commit into from
Jun 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/ui/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ impl Layout {
None
}
}

/// Propagate the given event to the command line.
fn command_line_handle_event(&mut self, event: Event) -> EventResult {
let is_left_right_event = matches!(event, Event::Key(Key::Left) | Event::Key(Key::Right));
let result = self.cmdline.on_event(event);

if self.cmdline.get_content().is_empty() {
self.clear_cmdline();
}

if is_left_right_event {
EventResult::Consumed(None)
} else {
result
}
}
}

impl View for Layout {
Expand Down Expand Up @@ -360,11 +376,7 @@ impl View for Layout {
}
Event::Key(Key::Esc) if self.cmdline_focus => self.clear_cmdline(),
_ if self.cmdline_focus => {
let result = self.cmdline.on_event(event);
if self.cmdline.get_content().is_empty() {
self.clear_cmdline();
}
return result;
return self.command_line_handle_event(event);
}
Event::Mouse {
position,
Expand Down
0