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
+46 -1
View File
@@ -15454,6 +15454,10 @@ fn shell_output_panel_clips_sanitized_content_in_offset_and_tiny_areas() {
#[test]
fn shell_output_wrap_toggle_reflows_and_scrolls_without_changing_source() {
let mut session = EditorSession::open(None, vec![], None).unwrap();
session
.editor_mut()
.bind("normal", "leader z w", Some("core.word_wrap.toggle".into()))
.unwrap();
let source_wrap = session.editor().word_wrap();
let source = session.editor().lines().to_vec();
session.editor_mut().show_command_output(
@@ -15467,6 +15471,10 @@ fn shell_output_wrap_toggle_reflows_and_scrolls_without_changing_source() {
.unwrap();
assert!(!screen_text(&terminal).contains("TAIL"));
session.handle(Input::Char('w'));
assert!(!session.editor().command_output().unwrap().wrapping);
for ch in " zw".chars() {
session.handle(Input::Char(ch));
}
terminal
.draw(|frame| views.draw_session(frame, &mut session))
.unwrap();
@@ -15475,7 +15483,9 @@ fn shell_output_wrap_toggle_reflows_and_scrolls_without_changing_source() {
assert_eq!(session.editor().command_output().unwrap().content.top, 1);
session.handle(Input::Right);
assert_eq!(session.editor().command_output().unwrap().content.left, 0);
session.handle(Input::Char('w'));
for ch in " zw".chars() {
session.handle(Input::Char(ch));
}
terminal
.draw(|frame| views.draw_session(frame, &mut session))
.unwrap();
@@ -15483,3 +15493,38 @@ fn shell_output_wrap_toggle_reflows_and_scrolls_without_changing_source() {
assert_eq!(session.editor().word_wrap(), source_wrap);
assert_eq!(session.editor().lines(), source);
}
#[test]
fn shell_output_wrap_bindings_respect_remaps_disabled_keys_and_sequence_cancellation() {
let mut editor = Editor::open(None, vec![]).unwrap();
editor
.bind("normal", "ctrl+y", Some("core.word_wrap.toggle".into()))
.unwrap();
editor
.bind("normal", "ctrl+w z", Some("core.word_wrap.toggle".into()))
.unwrap();
editor
.bind("normal", "leader x", Some("core.delete".into()))
.unwrap();
editor.show_command_output("command".into(), Err("output".into()));
let source = editor.lines().to_vec();
editor.handle(Input::Ctrl('y'));
assert!(editor.command_output().unwrap().wrapping);
editor.bind("normal", "ctrl+y", None).unwrap();
editor.handle(Input::Ctrl('y'));
assert!(editor.command_output().unwrap().wrapping);
editor.handle(Input::Ctrl('w'));
editor.handle(Input::Escape);
assert!(editor.command_output().is_some());
assert!(editor.sequence_pending().is_none());
editor.handle(Input::Ctrl('w'));
editor.handle(Input::Char('z'));
assert!(!editor.command_output().unwrap().wrapping);
editor.handle(Input::Char(' '));
editor.handle(Input::Char('x'));
assert_eq!(editor.lines(), source);
assert!(editor.command_output().is_some());
assert!(editor.sequence_pending().is_none());
editor.handle(Input::Escape);
assert!(editor.command_output().is_none());
}