feat: add pwsh-mouse-selection option#212
Conversation
새 세션 옵션 `pwsh-mouse-selection` 추가 (기본 off).
On일 때 Windows 11 PowerShell 스타일의 드래그 선택 동작을 제공합니다:
- pane 경계 존중 (rsel overlay clip)
- mouseup 후 선택 유지, 명시적 복사 시에만 해제
- 더블클릭 단어 선택, 트리플클릭 줄 선택
- Ctrl+클릭으로 선택 확장 (Shift+클릭은 Windows Terminal 예약)
- Alt+드래그 블록(사각형) 선택
- Ctrl+Shift+C / Ctrl+Shift+V / Ctrl+C 스마트 키바인딩
- 흰색 오버레이
기본값 off이므로 기존 사용자 동작 변경 없음.
리팩토링:
- `extract_selection_text` 내부 헬퍼(`PaneLeaf`/`collect_leaves`/`char_at_col`)를
module scope로 끌어올려 `word_bounds_at`와 공유
- `normalize_selection` 헬퍼 추출 (extract + render 중복 제거)
- `row_chars` 헬퍼로 word-scan O(n^2) -> O(n)
Closes psmux#211
|
I found a bug in copy and paste when applying the PR. I am leaving this here because I do not have time to fix it. |
Adds a new pwsh-mouse-selection session option (boolean, default off) that opts
into Windows 11 PowerShell parity selection behavior for the client side rsel
path.
When the option is on:
- Pane aware overlay clipping (fixes bleed into neighboring panes)
- Selection persists on mouse up (copy only via right click, Ctrl+Shift+C,
or smart Ctrl+C)
- Double click word / triple click line selection within originating pane
- Ctrl+click extends existing selection (Shift+click reserved by WT)
- Alt+drag produces rectangular (block) selection
- Ctrl+Shift+C (copy), Ctrl+Shift+V (paste), smart Ctrl+C bindings
- White overlay color (closer to Windows Terminal native selection)
Default stays off so existing behavior is unchanged.
Refactored PaneLeaf/collect_leaves/char_at_col from inside
extract_selection_text to module scope for reuse by word_bounds_at.
Added normalize_selection and row_chars helpers.
Added 9 regression tests in tests-rs/test_client.rs covering
normalize_selection, row_chars, char_at_col, is_word_char,
extract_selection_text block mode, word_bounds_at, and default option value.
Based on PR #212 by @jun2077681.
Closes #211.
|
Merged manually into master at commit 4b5b5a4 with 9 additional regression tests. All 904 tests pass. Thank you @jun2077681! |
1 similar comment
|
Merged manually into master at commit 4b5b5a4 with 9 additional regression tests. All 904 tests pass. Thank you @jun2077681! |
|
Hey @jun2077681, I apologize for missing your comment about the copy/paste bug earlier. I should have addressed that before closing. I went back and re reviewed the code carefully. I found and fixed one inconsistency in the right click copy cleanup path: it was not resetting I also ran the full Win32 TUI E2E test suite (8/8 pass) and verified:
Could you share a bit more about what specific copy/paste behavior you observed? For example:
Any details would help me track down and fix the exact issue you ran into. Thanks again for calling it out! |
The right-click copy handler was not clearing rsel_pane_rect and rsel_block after copying, while all other copy paths (Ctrl+Shift+C, smart Ctrl+C, legacy copy-on-release) properly reset both. This could leave stale pane clipping state and block mode flag across subsequent selections. Follow-up to PR #212 (pwsh-mouse-selection).
Summary
Adds a new
pwsh-mouse-selectionsession option (boolean, defaultoff) that opts into Windows 11 PowerShell-parity drag selection behaviour for the client-siderselpath.Closes #211.
When the option is on
rselpaints the full terminal width on intermediate rows, bleeding into neighbouring panes.Ctrl+Shift+C, or smartCtrl+C.Ctrl+Shift+C(copy),Ctrl+Shift+V(paste from clipboard), and smartCtrl+C(copy-if-selected, SIGINT otherwise).Default remains
off, so existing behaviour is unchanged for anyone who does not opt in.Usage
Changes
src/types.rs—AppState.pwsh_mouse_selectionfield + default.src/server/option_catalog.rs,src/server/options.rs,src/config.rs,src/server/mod.rs— option plumbing parallel toscroll-enter-copy-mode, andpwsh_mouse_selectionincluded in both dump JSON serialisation sites.src/client.rs—DumpState.pwsh_mouse_selectionfield,client_pwsh_selectionlocal mirroring the dump, and gated drag/key handlers.PaneLeaf/collect_leaves/char_at_colfrom insideextract_selection_textto module scope soword_bounds_atcan share them; addednormalize_selectionhelper used byextract_selection_textand the render path; addedrow_charshelper turning the double-click word scan from O(n²) to O(n).Notes
Ctrl+clickis used instead.rseloperates on visible content only, and scrolling the pane scrollback is copy mode's job.