fix: honor configured wrap bindings in shell output

This commit is contained in:
2026-10-18 01:28:26 +02:00
parent 074df97c02
commit e310b76794
4 changed files with 95 additions and 17 deletions
+47 -14
View File
@@ -4695,6 +4695,9 @@ impl Editor {
}
fn binding_mode(&self) -> Mode {
if self.command_output.is_some() {
return Mode::Normal;
}
if self.diff.is_some()
&& !self.diff_interacting()
&& !matches!(self.active.view.mode, Mode::Command | Mode::Search)
@@ -7008,22 +7011,29 @@ impl Editor {
}
fn handle_command_output(&mut self, input: &Input) -> bool {
let toggle = input == &Input::Char('w')
|| matches!(
self.bindings
.get(&self.binding_mode())
.and_then(|keys| keys.get(input)),
Some(Binding::Action(Action::WordWrapToggle))
);
let Some(output) = &mut self.command_output else {
if self.command_output.is_none() {
return false;
};
if toggle {
output.wrapping = !output.wrapping;
output.content.top = 0;
output.content.left = 0;
}
if self.sequence_pending().is_some() {
if matches!(input, Input::Escape | Input::Paste(_)) {
self.cancel_sequence();
} else {
self.handle_sequence(input.clone());
}
return true;
}
let mode = self.binding_mode();
if self.start_sequence(mode, input) {
return true;
}
if matches!(
self.bindings.get(&mode).and_then(|keys| keys.get(input)),
Some(Binding::Action(Action::WordWrapToggle))
) {
self.act(Action::WordWrapToggle);
return true;
}
let output = self.command_output.as_mut().unwrap();
let rows = if output.wrapping {
output.wrapped_rows.get()
} else {
@@ -8537,8 +8547,18 @@ impl Editor {
self.pending_sequence.keys.push(input);
let bindings = self.sequence_bindings.get(&self.binding_mode());
match bindings.and_then(|keys| keys.get(&self.pending_sequence)) {
Some(Binding::Action(action)) => return self.act(*action),
Some(Binding::Action(action)) => {
if self.command_output.is_some() && *action != Action::WordWrapToggle {
self.cancel_sequence();
return None;
}
return self.act(*action);
}
Some(Binding::Command(command)) => {
if self.command_output.is_some() {
self.cancel_sequence();
return None;
}
let command = command.clone();
return self.execute(&command);
}
@@ -9749,6 +9769,19 @@ impl Editor {
}
fn execute_action(&mut self, entry: &CoreAction, args: &str) -> Option<Invocation> {
if entry.action == Action::WordWrapToggle
&& let Some(output) = &mut self.command_output
{
if args.is_empty() {
output.wrapping = !output.wrapping;
output.content.top = 0;
output.content.left = 0;
} else {
self.set_message("The word_wrap.toggle command takes no arguments");
}
self.clear_sequence();
return None;
}
if matches!(
entry.action,
Action::DiffComment
+1 -1
View File
@@ -4715,7 +4715,7 @@ fn draw_diagnostic_panel(
Paragraph::new(if startup {
"Arrows scroll · Home reset · Enter/Esc continue"
} else {
"w wrap · Arrows scroll · Home reset · Enter/Esc close"
"Arrows scroll · Home reset · Enter/Esc close"
})
.style(Style::default().fg(Color::DarkGray)),
help_area,