Skip to content

Commit f439db4

Browse files
committed
Collapse multi-line copy previews and clarify Alt+M help
Keep the status flash single-line for short drag-selects, and make the help row describe mouse capture as a toggle with capture as the default.
1 parent 53cd8c1 commit f439db4

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎src/tui/keybindings.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const SHELL_SHORTCUTS: readonly ShellShortcut[] = [
2525
{ keys: "Ctrl+C", description: "interrupt the run, or clear the prompt when idle; press twice to exit" },
2626
{ keys: "Ctrl+G", description: "cancel the most recently queued or steered message before it dispatches" },
2727
{ keys: "Alt+C", description: "copy mode: pick a message, tool output, or diff; press again to close it" },
28-
{ keys: "Alt+M", description: "hand the mouse to the terminal for native drag-select; on by default so wheel scroll, click-to-expand, and drag-to-copy work" },
28+
{ keys: "Alt+M", description: "toggle DEC mouse capture (on by default: wheel scroll, click-to-expand, drag-to-copy); off restores native terminal drag-select" },
2929
{ keys: "Alt+E", description: "expand or collapse every collapsible row (tool call, diff, skill, reasoning)" },
3030
{ keys: "Alt+T", description: "show or hide the task list above the prompt" },
3131
{ keys: "Alt+O", description: "observe a live subagent session; a system row says so when there is none" },

‎src/tui/selection-copy.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,17 @@ describe("copyFinishedSelection", () => {
7676
expect(h.flashes[0]).toContain("…")
7777
expect(h.flashes[0]!.length).toBeLessThan(long.length + 40)
7878
})
79+
80+
test("collapses multi-line selections in the flash preview", () => {
81+
const h = host()
82+
const ok = copyFinishedSelection(h, {
83+
isDragging: false,
84+
getSelectedText: () => "ok\ngo",
85+
})
86+
expect(ok).toBe(true)
87+
expect(h.clipboard.writes).toEqual(["ok\ngo"])
88+
expect(h.flashes[0]).toContain("ok go")
89+
expect(h.flashes[0]).not.toContain("\n")
90+
})
7991
})
92+

‎src/tui/selection-copy.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ export function copyFinishedSelection(
3535
if (text.length === 0) return false
3636

3737
void host.clipboard.writeText(text)
38+
// Notice row is one line; always collapse whitespace so multi-line
39+
// drag-selects do not inject raw newlines into chrome.
40+
const oneLine = text.replace(/\s+/g, " ").trim()
3841
const preview =
39-
text.length > 48 ? `${text.slice(0, 45).replace(/\s+/g, " ")}…` : text
42+
oneLine.length > 48 ? `${oneLine.slice(0, 45)}…` : oneLine
4043
host.flash(`Copied ${text.length} chars: ${preview}`)
4144
host.clearSelection()
4245
return true

0 commit comments

Comments
 (0)