Skip to content

Commit 338d919

Browse files
authored
fix(ui): don't exit when typing 'q' in hexdump search and jump (#132)
1 parent d3b90ad commit 338d919

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/tui/command.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ pub enum HexdumpCommand {
160160
/// Cancel hexdump and move to the previous tab.
161161
CancelPrevious,
162162
/// Exit application.
163-
Exit,
163+
Exit(Event),
164164
}
165165

166166
impl HexdumpCommand {
167167
/// Parses the event.
168168
pub fn parse(key_event: KeyEvent, is_read_only: bool) -> Self {
169169
match key_event.code {
170-
KeyCode::Char('q') => Self::Exit,
170+
KeyCode::Char('q') => Self::Exit(Event::Key(key_event)),
171171
KeyCode::Tab => Self::CancelNext,
172172
KeyCode::BackTab => Self::CancelPrevious,
173173
KeyCode::Char('s') => {

src/tui/state.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,21 @@ impl<'a> State<'a> {
176176
.into();
177177
self.handle_tab()?;
178178
}
179-
HexdumpCommand::Exit => {
180-
self.running = false;
179+
HexdumpCommand::Exit(event) => {
180+
if self.analyzer.heh.key_handler.is_focusing(Window::Search)
181+
|| self
182+
.analyzer
183+
.heh
184+
.key_handler
185+
.is_focusing(Window::JumpToByte)
186+
{
187+
self.analyzer
188+
.heh
189+
.handle_input(&event)
190+
.map_err(|e| Error::HexdumpError(e.to_string()))?;
191+
} else {
192+
self.running = false;
193+
}
181194
}
182195
},
183196
Command::ShowDetails => {

0 commit comments

Comments
 (0)