From 5c7b0aab6702decdcccd993ccda97aba49bdb328 Mon Sep 17 00:00:00 2001 From: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Date: Wed, 12 Aug 2026 20:40:53 +0000 Subject: [PATCH] fix: preserve logical lines in scrollback editor refs #2733 --- docs/next/CHANGELOG.md | 1 + src/app/input/navigate.rs | 12 ++++++------ src/pane.rs | 4 ---- src/pane/terminal.rs | 5 +---- src/terminal/runtime.rs | 4 ---- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/docs/next/CHANGELOG.md b/docs/next/CHANGELOG.md index 428a973d..fc07ae15 100644 --- a/docs/next/CHANGELOG.md +++ b/docs/next/CHANGELOG.md @@ -19,6 +19,7 @@ - Experimental pane graphics now support bounded named layers, acknowledged full-RGBA primary-layer direct file frames on audited local terminals, owned BGRA fallback, exact pixel mouse input, and placement-only resize replay. ### Fixed +- `prefix+e` now preserves logical lines when opening soft-wrapped scrollback in an editor. (#2733) - Prefix keybindings now disambiguate layout-aware shifted punctuation, so a shifted `\` no longer triggers `prefix+|` on keyboard layouts where the same key produces both characters. (#2674) - Remote clients now continue redrawing at very large terminal sizes instead of freezing when a full ANSI frame exceeds the transport limit. (#2670) - OpenCode panes now track the root conversation selected in their own TUI for native restore without adopting activity from attached clients. (#2450) diff --git a/src/app/input/navigate.rs b/src/app/input/navigate.rs index beb2f363..afe9e6e0 100644 --- a/src/app/input/navigate.rs +++ b/src/app/input/navigate.rs @@ -975,7 +975,8 @@ impl App { .state .runtime_for_pane_in_workspace(&self.terminal_runtimes, ws_idx, pane_id) .ok_or_else(|| std::io::Error::other("focused pane has no scrollback runtime"))? - .recent_text(usize::MAX); + .recent_unwrapped_text_snapshot(usize::MAX) + .text; let path = write_scrollback_temp_file(&scrollback)?; @@ -3661,7 +3662,7 @@ navigate_pane_down = "ctrl+j" #[cfg(unix)] #[tokio::test] - async fn edit_scrollback_key_opens_focused_runtime_scrollback_in_editor_pane() { + async fn edit_scrollback_key_preserves_logical_lines_in_editor_pane() { let (_api_tx, api_rx) = tokio::sync::mpsc::unbounded_channel(); let mut app = App::new( &Config::default(), @@ -3675,10 +3676,10 @@ navigate_pane_down = "ctrl+j" workspace.tabs[0].runtimes.insert( root_pane, crate::terminal::TerminalRuntime::test_with_scrollback_bytes( - 20, + 5, 5, 4096, - b"alpha\nbeta\n", + b"ABCDEFGHIJ\r\nKLMNO", ), ); app.state.workspaces = vec![workspace]; @@ -3708,8 +3709,7 @@ navigate_pane_down = "ctrl+j" } let content = wait_for_file(&output_path); - assert!(content.contains("alpha")); - assert!(content.contains("beta")); + assert_eq!(content, "ABCDEFGHIJ\nKLMNO"); assert_eq!(app.state.mode, Mode::Terminal); assert!( app.state.terminals.values().any(|terminal| terminal diff --git a/src/pane.rs b/src/pane.rs index 83921ab0..44f3fea9 100644 --- a/src/pane.rs +++ b/src/pane.rs @@ -2727,10 +2727,6 @@ impl PaneRuntime { self.terminal.agent_osc_progress() } - pub fn recent_text(&self, lines: usize) -> String { - self.terminal.recent_text(lines) - } - pub(crate) fn recent_text_snapshot(&self, lines: usize) -> TerminalReadSnapshot { self.terminal.recent_text_snapshot(lines) } diff --git a/src/pane/terminal.rs b/src/pane/terminal.rs index 3524df21..b853f0b0 100644 --- a/src/pane/terminal.rs +++ b/src/pane/terminal.rs @@ -427,10 +427,6 @@ impl PaneTerminal { self.ghostty.detection_text() } - pub fn recent_text(&self, lines: usize) -> String { - self.ghostty.recent_text(lines) - } - pub(crate) fn recent_text_snapshot(&self, lines: usize) -> TerminalReadSnapshot { self.ghostty.recent_text_snapshot(lines) } @@ -1959,6 +1955,7 @@ impl GhosttyPaneTerminal { .unwrap_or_default() } + #[cfg(test)] pub fn recent_text(&self, lines: usize) -> String { self.recent_text_snapshot(lines).text } diff --git a/src/terminal/runtime.rs b/src/terminal/runtime.rs index 89544a74..156d18fd 100644 --- a/src/terminal/runtime.rs +++ b/src/terminal/runtime.rs @@ -361,10 +361,6 @@ impl TerminalRuntime { self.0.agent_osc_progress() } - pub fn recent_text(&self, lines: usize) -> String { - self.0.recent_text(lines) - } - pub(crate) fn recent_text_snapshot(&self, lines: usize) -> crate::pane::TerminalReadSnapshot { self.0.recent_text_snapshot(lines) }