Skip to content

Fix Support of Bracketed Paste Mode in Client/Server session #1170

@dragonfyre13

Description

@dragonfyre13

Symptoms first. When pasting via Ctrl+Shift+V in hterm (crostini, on ChromeOS), it always instead pastes something like [200~PASTED TEXT HERE[201~, where "PASTED TEXT HERE" is obviously the text that was in the clipboard.

Note, if auto-close brackets is enabled, the pasted text instead is [200~PASTED TEXT HERE[201~]] with the cursor immediately after the 2nd tilde, since pasted text is being interpreted as "typed" instead of "pasted" text.

The reason this is happening is because fresh doesn't support Bracketed Paste Mode (which is a very standard thing most terminal editors and terminals themselves do support, see sh, bash, ksh, zsh, nano, vi, vim, emacs, pico, etc.). See here for some details on it, but basically it's just the terminals way of saying "this is pasted text vs typed text". In the case of fresh, it doesn't even absolutely need to treat it differently (though it almost certainly should, as noted above, at least ignoring auto-close characters and preferably auto-indent when inserting pasted text). Regardless, we should exclude the standard control sequences for pasted text, given it's intercepting things directly.

ESC [200~ to signify the beginning of pasted text and
ESC [201~ to signify the end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions