Skip to content

fix: handle \\\\ escape in parse_command_line (backslash key broken in panes)#123

Closed
schgoo wants to merge 2 commits into
psmux:masterfrom
schgoo:master
Closed

fix: handle \\\\ escape in parse_command_line (backslash key broken in panes)#123
schgoo wants to merge 2 commits into
psmux:masterfrom
schgoo:master

Conversation

@schgoo

@schgoo schgoo commented Mar 17, 2026

Copy link
Copy Markdown

Fix for #122

psmux pushed a commit that referenced this pull request Mar 18, 2026
… right-click, CRLF)

Fix 6 bugs in client-server mode reported in #118:

1. display-message: handler now sets app.status_message when not using
   -p flag, so messages actually appear on the status bar.

2. Mouse multi-client tracking: all 10 mouse/scroll CtrlReq variants now
   carry client_id. Server updates latest_client_id on mouse events so
   coordinate processing uses the clicking client's dimensions.

3. Popup race condition: added 50ms delay after PTY spawn in display-popup
   so the reader thread can populate the vt100 parser before the first
   frame is serialized to clients. Prevents blank popups with fast commands.

4. Paste fragmentation: added growth detection to stage2 timeout. If the
   paste_pend buffer grew since the last check, the timeout is extended
   instead of splitting the paste. Large non-ASCII buffers (>=20 chars)
   now enter stage2 instead of being flushed as IME input.

5. Right-click copy paste suppression: after right-click copy, text key
   events are suppressed for 2s to prevent VS Code ConPTY from injecting
   duplicate clipboard content as key events.

6. Clipboard CRLF normalization: read_from_system_clipboard() now normalizes
   Windows CRLF line endings to LF, preventing double-spaced paste output.

Also includes the parse_command_line \\\\ escape fix from #123.
psmux pushed a commit that referenced this pull request Mar 18, 2026
Fix 6 bugs in client-server mode reported by @ToxMox in #118:

1. display-message: handler now sets app.status_message when not using
   -p flag, so messages actually appear on the status bar.

2. Mouse multi-client tracking: all 10 mouse/scroll CtrlReq variants now
   carry client_id. Server updates latest_client_id on mouse events so
   coordinate processing uses the clicking client's dimensions.

3. Popup race condition: added 50ms delay after PTY spawn in display-popup
   so the reader thread can populate the vt100 parser before the first
   frame is serialized to clients. Prevents blank popups with fast commands.

4. Paste fragmentation: added growth detection to stage2 timeout. If the
   paste_pend buffer grew since the last check, the timeout is extended
   instead of splitting the paste. Large non-ASCII buffers (>=20 chars)
   now enter stage2 instead of being flushed as IME input.

5. Right-click copy paste suppression: after right-click copy, text key
   events are suppressed for 2s to prevent VS Code ConPTY from injecting
   duplicate clipboard content as key events.

6. Clipboard CRLF normalization: read_from_system_clipboard() now normalizes
   Windows CRLF line endings to LF, preventing double-spaced paste output.

Also fixes parse_command_line backslash escape reported by @schgoo in #123.
The parser now recognises \\ as an escape sequence inside double quotes
(producing a single \), preventing the closing quote from being consumed
when the client sends send-text "\\".

Co-investigated-by: @ToxMox (#118)
Co-investigated-by: @schgoo (#123)
@psmux

psmux commented Mar 18, 2026

Copy link
Copy Markdown
Owner

Hey @schgoo, nice catch! Your fix is spot-on — the parse_command_line parser was only handling \" as an escape inside double quotes, so send-text "\\" (the client's encoding for a single backslash) had its second \ steal the closing quote via the \" rule. Result: the PTY received \" instead of \, and the shell showed " + >> continuation prompt.

I've landed the same core fix in commit b37c89e — adding \\ as a recognized escape sequence (producing a single \), which is identical to what your PR does. Also adopted your unit tests idea and added a test script for end-to-end verification.

Thanks for the clean analysis and the tests — really appreciate the contribution. Closing this since the fix is already on master, but you're credited in the commit. Cheers!

@schgoo

schgoo commented Mar 18, 2026

Copy link
Copy Markdown
Author

Nice! Thanks for getting to this so quickly!

@psmux

psmux commented Mar 19, 2026

Copy link
Copy Markdown
Owner

You're welcome! Share the good news about Psmux!

ohboyftw pushed a commit to ohboyftw/psmux that referenced this pull request Mar 19, 2026
Brings 17 upstream commits into ohboy-builds:
- fix: warm claim race condition (psmux#136)
- fix: client_prefix flag, window_zoomed_flag (psmux#125, psmux#126)
- fix: Shift+Enter/Ctrl+Enter modifiers, paste normalization (psmux#131, psmux#132)
- fix: backslash escape, 6 client-server bugs (psmux#118, psmux#123)
- fix: -f global option (psmux#119)
- fix: set-hook replace/remove, zoomed navigation wrap (psmux#133, psmux#134)
- fix: TERM env var mapping, hyphenated option leak (psmux#137)
- feat: bell/activity/silence monitoring, allow-rename, update-environment
- feat: vim-style bind-key C-hjkl pane navigation (psmux#130)
- feat: XDG plugin path support (psmux#135)
- feat: auto-generate changelog in release workflow
- refactor: move Rust tests to tests-rs/ directory
- refactor: rich test dashboard

Also applies ohboy-builds stashed changes:
- Remove claude-code-fix-tty (Claude Code now auto-detects $TMUX)
- Migrate env::set_var to safe crate::util::set_env wrappers (Rust 1.83)
- Selection clamp to pane boundaries in copy mode
- Fix clippy warnings in forked crates (vt100-psmux, portable-pty-psmux)
souhaiebtar pushed a commit to souhaiebtar/psmux that referenced this pull request Mar 20, 2026
Fix 6 bugs in client-server mode reported by @ToxMox in psmux#118:

1. display-message: handler now sets app.status_message when not using
   -p flag, so messages actually appear on the status bar.

2. Mouse multi-client tracking: all 10 mouse/scroll CtrlReq variants now
   carry client_id. Server updates latest_client_id on mouse events so
   coordinate processing uses the clicking client's dimensions.

3. Popup race condition: added 50ms delay after PTY spawn in display-popup
   so the reader thread can populate the vt100 parser before the first
   frame is serialized to clients. Prevents blank popups with fast commands.

4. Paste fragmentation: added growth detection to stage2 timeout. If the
   paste_pend buffer grew since the last check, the timeout is extended
   instead of splitting the paste. Large non-ASCII buffers (>=20 chars)
   now enter stage2 instead of being flushed as IME input.

5. Right-click copy paste suppression: after right-click copy, text key
   events are suppressed for 2s to prevent VS Code ConPTY from injecting
   duplicate clipboard content as key events.

6. Clipboard CRLF normalization: read_from_system_clipboard() now normalizes
   Windows CRLF line endings to LF, preventing double-spaced paste output.

Also fixes parse_command_line backslash escape reported by @schgoo in psmux#123.
The parser now recognises \\ as an escape sequence inside double quotes
(producing a single \), preventing the closing quote from being consumed
when the client sends send-text "\\".

Co-investigated-by: @ToxMox (psmux#118)
Co-investigated-by: @schgoo (psmux#123)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants