fix: trim trailing whitespace from terminal clipboard copies#3167
fix: trim trailing whitespace from terminal clipboard copies#3167Drew-Goddyn wants to merge 1 commit intowavetermdev:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
WalkthroughThis PR introduces a new optional feature for trimming trailing whitespace from terminal text selections across the application. A new setting Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes wavetermdev#2778. xterm.js getSelection() returns lines padded to the full terminal column width, resulting in hundreds of trailing spaces when pasting into external apps. Adds a term:trimtrailingwhitespace setting (default true) that strips trailing whitespace from each line before writing to the clipboard. Applies to all three copy paths: copy-on-select, Ctrl+Shift+C, and right-click Copy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4817f82 to
b3cc6ae
Compare
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (7 files)
The implementation correctly handles the optional boolean setting using the Reviewed by minimax-m2.5-20260211 · 348,289 tokens |
Fixes #2778.
Problem
xterm.js'sgetSelection()returns lines padded to the full terminal column width. Every copy path passed this directly tonavigator.clipboard.writeText(), so pasting into Slack, editors, etc. included hundreds of trailing spaces.Solution
Adds a
term:trimtrailingwhitespacesetting (defaulttrue) that strips trailing whitespace from each line before writing to the clipboard. Applied to all three copy paths:termwrap.ts)Ctrl+Shift+C(term-model.ts)term-model.ts)OSC 52 is intentionally excluded — that path copies program-provided text, not grid content.
The trim itself uses the same per-line
trimEnd()approach already present inbufferLinesToTextviatranslateToString(true).Setting to
falserestores the previous behaviour.Files changed
pkg/wconfig/settingsconfig.go— newTermTrimTrailingWhitespace *boolfieldpkg/wconfig/defaultconfig/settings.json— defaulttruefrontend/app/view/term/termutil.ts—trimTerminalSelectionhelperfrontend/app/view/term/termwrap.ts— copy-on-select pathfrontend/app/view/term/term-model.ts— Ctrl+Shift+C and right-click pathspkg/wconfig/metaconsts.go,frontend/types/gotypes.d.ts,schema/settings.json🤖 Generated with Claude Code