Skip to content

Commit 7d91538

Browse files
sinelawclaude
andcommitted
Enable split navigation commands in terminal mode and restore terminal state
- Add Terminal context to split navigation commands (Next/Previous Split, Close Split, Increase/Decrease Split Size, Toggle Maximize Split) so they are available in command palette when terminal is focused - Restore terminal mode when switching to a terminal split via next/prev split commands, matching the behavior of click-based split switching 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 2f65934 commit 7d91538

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/app/mod.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,18 +2102,30 @@ impl Editor {
21022102

21032103
/// Switch to next split
21042104
pub fn next_split(&mut self) {
2105-
self.save_current_split_view_state();
2106-
self.split_manager.next_split();
2107-
self.restore_current_split_view_state();
2105+
self.switch_split(true);
21082106
self.set_status_message("Switched to next split".to_string());
21092107
}
21102108

21112109
/// Switch to previous split
21122110
pub fn prev_split(&mut self) {
2111+
self.switch_split(false);
2112+
self.set_status_message("Switched to previous split".to_string());
2113+
}
2114+
2115+
/// Common split switching logic
2116+
fn switch_split(&mut self, next: bool) {
21132117
self.save_current_split_view_state();
2114-
self.split_manager.prev_split();
2118+
if next {
2119+
self.split_manager.next_split();
2120+
} else {
2121+
self.split_manager.prev_split();
2122+
}
21152123
self.restore_current_split_view_state();
2116-
self.set_status_message("Switched to previous split".to_string());
2124+
// Enter terminal mode if switching to a terminal split
2125+
if self.is_terminal_buffer(self.active_buffer()) {
2126+
self.terminal_mode = true;
2127+
self.key_context = crate::input::keybindings::KeyContext::Terminal;
2128+
}
21172129
}
21182130

21192131
/// Save the current split's cursor state (viewport is owned by SplitViewState)

src/input/commands.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,47 +423,47 @@ pub fn get_all_commands() -> Vec<Command> {
423423
name: "Close Split".to_string(),
424424
description: "Close the current split pane".to_string(),
425425
action: Action::CloseSplit,
426-
contexts: vec![KeyContext::Normal],
426+
contexts: vec![KeyContext::Normal, KeyContext::Terminal],
427427
custom_contexts: vec![],
428428
source: CommandSource::Builtin,
429429
},
430430
Command {
431431
name: "Next Split".to_string(),
432432
description: "Move focus to the next split pane".to_string(),
433433
action: Action::NextSplit,
434-
contexts: vec![KeyContext::Normal],
434+
contexts: vec![KeyContext::Normal, KeyContext::Terminal],
435435
custom_contexts: vec![],
436436
source: CommandSource::Builtin,
437437
},
438438
Command {
439439
name: "Previous Split".to_string(),
440440
description: "Move focus to the previous split pane".to_string(),
441441
action: Action::PrevSplit,
442-
contexts: vec![KeyContext::Normal],
442+
contexts: vec![KeyContext::Normal, KeyContext::Terminal],
443443
custom_contexts: vec![],
444444
source: CommandSource::Builtin,
445445
},
446446
Command {
447447
name: "Increase Split Size".to_string(),
448448
description: "Increase the size of the current split".to_string(),
449449
action: Action::IncreaseSplitSize,
450-
contexts: vec![KeyContext::Normal],
450+
contexts: vec![KeyContext::Normal, KeyContext::Terminal],
451451
custom_contexts: vec![],
452452
source: CommandSource::Builtin,
453453
},
454454
Command {
455455
name: "Decrease Split Size".to_string(),
456456
description: "Decrease the size of the current split".to_string(),
457457
action: Action::DecreaseSplitSize,
458-
contexts: vec![KeyContext::Normal],
458+
contexts: vec![KeyContext::Normal, KeyContext::Terminal],
459459
custom_contexts: vec![],
460460
source: CommandSource::Builtin,
461461
},
462462
Command {
463463
name: "Toggle Maximize Split".to_string(),
464464
description: "Maximize or restore the current split".to_string(),
465465
action: Action::ToggleMaximizeSplit,
466-
contexts: vec![KeyContext::Normal],
466+
contexts: vec![KeyContext::Normal, KeyContext::Terminal],
467467
custom_contexts: vec![],
468468
source: CommandSource::Builtin,
469469
},

0 commit comments

Comments
 (0)