bracketed paste in conhost #596

Closed
opened 2026-01-30 21:56:26 +00:00 by claunia · 22 comments
Owner

Originally created by @davidanthoff on GitHub (Mar 27, 2019).

Does the Windows console support bracket paste mode? I wasn't able to find any information about that.

Originally created by @davidanthoff on GitHub (Mar 27, 2019). Does the Windows console support [bracket paste mode](https://wpdev.uservoice.com/forums/266908)? I wasn't able to find any information about that.
claunia added the Issue-FeatureProduct-ConhostWork-ItemIn-PRArea-VTNeeds-Tag-Fix labels 2026-01-30 21:56:27 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 27, 2019):

Funny you should ask! I've been working on this one myself, as I'd love to see it land.
I'll mark this one with our backlog/tracking tags.

@DHowett-MSFT commented on GitHub (Mar 27, 2019): Funny you should ask! I've been working on this one myself, as I'd love to see it land. I'll mark this one with our backlog/tracking tags.
Author
Owner

@vapier commented on GitHub (Mar 27, 2019):

one suggestion to keep in mind (as I've seen more than one implementation forget this edge case): make sure to filter out control sequences when pasting. otherwise the buffer could embed the end sequence thus defeating the point of it.

if you want to be compatible with xterm (who invented this feature), you want to filter:
\x00-\x07
\x0b-\x0c
\x0e-\x1f

@vapier commented on GitHub (Mar 27, 2019): one suggestion to keep in mind (as I've seen more than one implementation forget this edge case): make sure to filter out control sequences when pasting. otherwise the buffer could embed the end sequence thus defeating the point of it. if you want to be compatible with xterm (who invented this feature), you want to filter: \x00-\x07 \x0b-\x0c \x0e-\x1f
Author
Owner

@oising commented on GitHub (Mar 27, 2019):

@DHowett-MSFT -- worth ingesting this page here concerning the security issues various implementations of bracketed paste mode may have: https://lwn.net/Articles/749992/ -- particularly http://thejh.net/misc/website-terminal-copy-paste

@oising commented on GitHub (Mar 27, 2019): @DHowett-MSFT -- worth ingesting this page here concerning the security issues various implementations of bracketed paste mode may have: https://lwn.net/Articles/749992/ -- particularly http://thejh.net/misc/website-terminal-copy-paste
Author
Owner

@miniksa commented on GitHub (Mar 27, 2019):

@oising, thank you for that read. I think the best thing we could do is write tests for the specific security issues listed there and attempt to mitigate them as we implement the bracketed paste mode.

@miniksa commented on GitHub (Mar 27, 2019): @oising, thank you for that read. I think the best thing we could do is write tests for the specific security issues listed there and attempt to mitigate them as we implement the bracketed paste mode.
Author
Owner

@chris-morgan commented on GitHub (Nov 10, 2019):

Would it be possible and/or reasonable for starters to just have ConPTY pass through ESC [ ? 2004 h and ESC [ ? 2004 l on stdout, and ESC [ 200 ~ and ESC [ 201 ~ on stdin, so that other terminals that support bracketed paste (e.g. Alacritty) can support it? (It makes me sad when such terminal emulators are blocked from supporting functionality on Windows because ConPTY filters out the magic.)

@chris-morgan commented on GitHub (Nov 10, 2019): Would it be possible and/or reasonable for starters to just have ConPTY pass through `ESC [ ? 2004 h` and `ESC [ ? 2004 l` on stdout, and `ESC [ 200 ~` and `ESC [ 201 ~` on stdin, so that other terminals that support bracketed paste (e.g. Alacritty) can support it? (It makes me sad when such terminal emulators are blocked from supporting functionality on Windows because ConPTY filters out the magic.)
Author
Owner

@FlipperPA commented on GitHub (Mar 16, 2020):

@DHowett Dustin, thanks for pointing me to this issue from the one I had opened concerning pasting into IPython / vi. Are there any workarounds in the meantime?

@FlipperPA commented on GitHub (Mar 16, 2020): @DHowett Dustin, thanks for pointing me to this issue from the one I had opened concerning pasting into IPython / vi. Are there any workarounds in the meantime?
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 16, 2020):

In the meantime, before/after pasting in vim you can :set paste and :set nopaste. I'm not certain what ipy needs here, unfortunately. ☹️

@DHowett-MSFT commented on GitHub (Mar 16, 2020): In the meantime, before/after pasting in vim you can `:set paste` and `:set nopaste`. I'm not certain what ipy needs here, unfortunately. ☹️
Author
Owner

@FlipperPA commented on GitHub (Mar 22, 2020):

Several similar workarounds for ipython on Ubuntu for anyone looking:

  • Type %autoindent to turn off automatic indentation, then pasting will work.
  • Type %cpaste and then paste, and then -- to end, and it will work, if you want to leave automatic indentation on.

This will not persist between ipython sessions. To make this change permanent, you can create a configuration file a la vi ~/.ipython/profile_default/ipython_config.py, and put these contents in it:

c = get_config()
c.InteractiveShell.autoindent = False

I hope this helps someone!

@FlipperPA commented on GitHub (Mar 22, 2020): Several similar workarounds for `ipython` on Ubuntu for anyone looking: * Type `%autoindent` to turn off automatic indentation, then pasting will work. * Type `%cpaste` and then paste, and then `--` to end, and it will work, if you want to leave automatic indentation on. This will not persist between `ipython` sessions. To make this change permanent, you can create a configuration file a la `vi ~/.ipython/profile_default/ipython_config.py`, and put these contents in it: ``` c = get_config() c.InteractiveShell.autoindent = False ``` I hope this helps someone!
Author
Owner

@skyline75489 commented on GitHub (Feb 14, 2021):

For the 8 people who subscribed this (one of them being an obsolete account of Dustin), the bracketed paste mode in Windows Terminal is implemented in #9034 and should be available in 1.7 preview 🎉 .

Thanks everyone for the discussion about the potential security issues. I believe most of them has been taken care of in the implementation. Feel free to contact me if you have any questions about the current implementation.

@skyline75489 commented on GitHub (Feb 14, 2021): For the 8 people who subscribed this (one of them being an obsolete account of Dustin), the bracketed paste mode in Windows Terminal is implemented in #9034 and should be available in 1.7 preview 🎉 . Thanks everyone for the discussion about the potential security issues. I believe most of them has been taken care of in the implementation. Feel free to contact me if you have any questions about the current implementation.
Author
Owner

@oising commented on GitHub (Feb 16, 2021):

@skyline75489 ! Woo

@oising commented on GitHub (Feb 16, 2021): @skyline75489 ! Woo
Author
Owner

@FlipperPA commented on GitHub (Feb 19, 2021):

This is fantastic, @skyline75489 - thank you to everyone who worked on it.

@FlipperPA commented on GitHub (Feb 19, 2021): This is fantastic, @skyline75489 - thank you to everyone who worked on it.
Author
Owner

@gbtec-markusmeier commented on GitHub (Mar 3, 2021):

Wasn't subscribing, but watching silently for some months - just saw that @cinnamon-msft mentioned this great feature in Terminal Preview 1.7. Looking forward to next month's release!

@gbtec-markusmeier commented on GitHub (Mar 3, 2021): Wasn't subscribing, but watching silently for some months - just saw that @cinnamon-msft mentioned this great feature in Terminal Preview 1.7. Looking forward to next month's release!
Author
Owner

@DHowett commented on GitHub (Mar 3, 2021):

@gbtec-markusmeier Preview is fairly stable itself; you could switch over today!

@DHowett commented on GitHub (Mar 3, 2021): @gbtec-markusmeier Preview is fairly stable itself; you could switch over today!
Author
Owner

@davidanthoff commented on GitHub (Mar 3, 2021):

Fantastic, thanks for implementing this! I'm closing this issue, because I guess it is all done :)

@davidanthoff commented on GitHub (Mar 3, 2021): Fantastic, thanks for implementing this! I'm closing this issue, because I guess it is all done :)
Author
Owner

@skyline75489 commented on GitHub (Mar 3, 2021):

@davidanthoff my work is to bring bracketed paste into Windows Terminal. The support for bracketed paste in Conhost is yet to be done. I understand this issue is probably opened when Windows Terminal wasn’t really a thing, but here it is.

We may want to reopen this and change the title to just “bracketed paste in conhost”.

@skyline75489 commented on GitHub (Mar 3, 2021): @davidanthoff my work is to bring bracketed paste into Windows Terminal. The support for bracketed paste in Conhost is yet to be done. I understand this issue is probably opened when Windows Terminal wasn’t really a thing, but here it is. We may want to reopen this and change the title to just “bracketed paste in conhost”.
Author
Owner

@davidanthoff commented on GitHub (Mar 4, 2021):

Done!

@davidanthoff commented on GitHub (Mar 4, 2021): Done!
Author
Owner

@FlipperPA commented on GitHub (Mar 4, 2021):

Just a big THANK YOU to everyone involved - this is a huge time saver and help for my workflow.

@FlipperPA commented on GitHub (Mar 4, 2021): Just a big THANK YOU to everyone involved - this is a huge time saver and help for my workflow.
Author
Owner

@blayz3r commented on GitHub (Mar 9, 2021):

@davidanthoff my work is to bring bracketed paste into Windows Terminal. The support for bracketed paste in Conhost is yet to be done. I understand this issue is probably opened when Windows Terminal wasn’t really a thing, but here it is.

We may want to reopen this and change the title to just “bracketed paste in conhost”.

So bracketed paste will not work in ConPTY atm? correct?

@blayz3r commented on GitHub (Mar 9, 2021): > > > @davidanthoff my work is to bring bracketed paste into Windows Terminal. The support for bracketed paste in Conhost is yet to be done. I understand this issue is probably opened when Windows Terminal wasn’t really a thing, but here it is. > > We may want to reopen this and change the title to just “bracketed paste in conhost”. So bracketed paste will not work in ConPTY atm? correct?
Author
Owner

@zadjii-msft commented on GitHub (Mar 9, 2021):

No it should work just fine in conpty (the Terminal uses conpty too 😉). Conhost (the vintage console) still needs to implement support for this itself, but that should be much simpler now.

@zadjii-msft commented on GitHub (Mar 9, 2021): No it should work just fine in conpty (the Terminal uses conpty too 😉). Conhost (the vintage console) still needs to implement support for this itself, but that should be much simpler now.
Author
Owner

@blayz3r commented on GitHub (Mar 9, 2021):

No it should work just fine in conpty (the Terminal uses conpty too 😉). Conhost (the vintage console) still needs to implement support for this itself, but that should be much simpler now.

Ok great, is there a preview version on ConPty. or do we have to wait for the new release:
Context using conpty in Gvim:
image

@blayz3r commented on GitHub (Mar 9, 2021): > > > No it should work just fine in conpty (the Terminal uses conpty too 😉). Conhost (the vintage console) still needs to implement support for this itself, but that should be much simpler now. Ok great, is there a preview version on ConPty. or do we have to wait for the new release: Context using conpty in Gvim: ![image](https://user-images.githubusercontent.com/12205650/110487098-3e749700-80bb-11eb-9c41-bdccccb39fac.png)
Author
Owner

@dashesy commented on GitHub (Oct 22, 2022):

I have 1.15.2875.0 but this seems to be unsupported still.

@dashesy commented on GitHub (Oct 22, 2022): I have 1.15.2875.0 but this seems to be unsupported still.
Author
Owner

@DHowett commented on GitHub (Oct 22, 2022):

I have 1.15.2875.0 but this seems to be unsupported still.

@dashesy i would encourage you to file a new issue and fill out the issue template. As far as we are aware, paste bracketing works fine for every client application that requests it. Filing a new issue would be the best way to draw attention to, and provide specific information about, the problem you're facing.

@DHowett commented on GitHub (Oct 22, 2022): > I have 1.15.2875.0 but this seems to be unsupported still. @dashesy i would encourage you to file a new issue and fill out the issue template. As far as we are aware, paste bracketing works fine for every client application that requests it. Filing a new issue would be the best way to draw attention to, and provide specific information about, the problem you're facing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#596