Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable bracketed paste during the execution of a child #10998

Conversation

LevitatingBusinessMan
Copy link

Fixes #10982

Based on by #9399 by @WindSoilder.

I invite @WindSoilder, @fdncred and @theAkito to test this on their respective platforms.

I can't say I completely understand nushells cli code, but based on @WindSoilder I assumed eval_source was responsible for executing the child program.

This PR disables bracketed paste during the execution of children for reasons I explained in #10982.

To test:

1. cargo update
2. cargo run
3. cat
4. paste something inside

With this all bracketed paste issues should be fixed.

if engine_state.get_config().bracketed_paste {
#[cfg(not(target_os = "windows"))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably stay because I don't believe bracketed paste is supported on Windows yet. IIRC, there was a crossterm issue about it, unless you're saying that's been fixed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably stay because I don't believe bracketed paste is supported on Windows yet. IIRC, there was a crossterm issue about it, unless you're saying that's been fixed?

I haven't looked into bracketed_paste much from the crossterm side. However it should be totally dependent on the terminal, not on the OS itself. And we can't assume that a windows user is using any specific terminal.

This is why I asked for multiple people to test it on multiple platforms, to see if something breaks.

I don't like the solution of giving Windows users a configuration setting that is silently ignored either. Either they can or they can't configure bracketed paste.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If bracketed paste isn't supported in a certain terminal (some unix terminals might not support it either) at its worst the control characters are probably just ignored. So there should be no harm in having it enabled on a terminal that does not support it.

According to crossterm-rs/crossterm#737, bracketed paste does work in WizTerm on Windows.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super sure how to test this to ensure my buffer has the appropriate escape sequences when I paste them. But these seem to work on Windows Terminal and WezTerm.

❯ $"(ansi csi)200~this is a test(ansi csi)201~"
this is a test
❯ $"(ansi csi)?2004h(ansi csi)200~this is a test(ansi csi)201~(ansi csi)?2004l"
this is a test

@fdncred
Copy link
Collaborator

fdncred commented Nov 8, 2023

It would also be good to have reedline updated in this PR since it's required, I think, right?

@LevitatingBusinessMan
Copy link
Author

It would also be good to have reedline updated in this PR since it's required, I think, right?

This shouldn't have negative effects on the reedline crate before the patch. If you want to bump the reedline version in nushell you'll have to release a new reedline version. 0.25.1 or 0.26.0

@fdncred
Copy link
Collaborator

fdncred commented Nov 8, 2023

I'm saying that we should be testing with the latest version of reedline so cargo update -p reedline needs to be done somewhere in some PR and this seems like as good of one as any since it's related to the most recent changes in reedline.

@LevitatingBusinessMan
Copy link
Author

LevitatingBusinessMan commented Nov 8, 2023

I'm saying that we should be testing with the latest version of reedline so cargo update -p reedline needs to be done somewhere in some PR and this seems like as good of one as any since it's related to the most recent changes in reedline.

But reedline is still on version 0.25.0, and only the development build is configured to build reedline from git. (Edit: It's not)

Are you saying I should commit the updated Cargo.tomllock referencing the latest git commit for reedline?

@WindSoilder
Copy link
Collaborator

Are you saying I should commit the updated Cargo.toml referencing the latest git commit for reedline?

Actually you don't need to, I found that it already use latest git commit of reedline

@LevitatingBusinessMan
Copy link
Author

Are you saying I should commit the updated Cargo.toml referencing the latest git commit for reedline?

Actually you don't need to, I found that it already use latest git commit of reedline

I think it uses whatever version is specified in the lockfile.

I compiled nushell from a fresh clone, and it still had nushell/reedline#648, the bug where bracketed_paste only works the first time because it gets disabled after the first time. Then I ran cargo update -p reedline updating the used commit:

    Updating reedline v0.25.0 (https://github.com/nushell/reedline.git?branch=main#973dbb5f) -> #c853d71e

I was wrong thinking that the patch.crates-io only applied to debug builds, it also applies to the release build. So @fdncred do you want me to commit the updated Cargo.lock to the PR?

@LevitatingBusinessMan
Copy link
Author

I updated the commit hash, but I really think it would be better if reedline would just release regular patch version bumps.

@fdncred
Copy link
Collaborator

fdncred commented Nov 10, 2023

Then I ran cargo update -p reedline updating the used commit ...

This is why I asked you to do it the other day. Glad you figured it out.

I think at this point I'd like to see what @sholderbach's PR reveals nushell/reedline#659 and how it intersects with this PR.

sholderbach added a commit to sholderbach/nushell that referenced this pull request Nov 13, 2023
Go from the ill-defined `enable/disable` pairs to `.use_...` builders
This alleviates unclear properties when the underlying enhancements are
enabled. Now they are enabed when entering `Reedline::read_line` and
disabled when exiting that.

Furthermore allow setting `$env.config.use_kitty_protocol` to have an
effect when toggling during runtime. Previously it was only enabled when
receiving a value from `config.nu`. I kept the warning code there to not
pollute the log. We could move it into the REPL-loop if desired

Not sure if we should actively block the enabling of `bracketed_paste`
on Windows. Need to test what happens if it just doesn't do anything we
could remove the `cfg!` switch. At least for WSL2 Windows Terminal
already supports bracketed paste. `target_os = windows` is a bad
predictor for `conhost.exe`.

Depends on nushell/reedline#659
(pointing to personal fork)

Closes nushell#10982
Supersedes nushell#10998
sholderbach added a commit that referenced this pull request Nov 14, 2023
Go from the ill-defined `enable/disable` pairs to `.use_...` builders
This alleviates unclear properties when the underlying enhancements are
enabled. Now they are enabed when entering `Reedline::read_line` and
disabled when exiting that.

Furthermore allow setting `$env.config.use_kitty_protocol` to have an
effect when toggling during runtime. Previously it was only enabled when
receiving a value from `config.nu`. I kept the warning code there to not
pollute the log. We could move it into the REPL-loop if desired

Not sure if we should actively block the enabling of `bracketed_paste`
on Windows. Need to test what happens if it just doesn't do anything we
could remove the `cfg!` switch. At least for WSL2 Windows Terminal
already supports bracketed paste. `target_os = windows` is a bad
predictor for `conhost.exe`.

Depends on nushell/reedline#659
(pointing to personal fork)

Closes #10982
Supersedes #10998
@sholderbach
Copy link
Member

Thanks for the PR @LevitatingBusinessMan

superseded by #11045

hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
Go from the ill-defined `enable/disable` pairs to `.use_...` builders
This alleviates unclear properties when the underlying enhancements are
enabled. Now they are enabed when entering `Reedline::read_line` and
disabled when exiting that.

Furthermore allow setting `$env.config.use_kitty_protocol` to have an
effect when toggling during runtime. Previously it was only enabled when
receiving a value from `config.nu`. I kept the warning code there to not
pollute the log. We could move it into the REPL-loop if desired

Not sure if we should actively block the enabling of `bracketed_paste`
on Windows. Need to test what happens if it just doesn't do anything we
could remove the `cfg!` switch. At least for WSL2 Windows Terminal
already supports bracketed paste. `target_os = windows` is a bad
predictor for `conhost.exe`.

Depends on nushell/reedline#659
(pointing to personal fork)

Closes nushell#10982
Supersedes nushell#10998
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
Go from the ill-defined `enable/disable` pairs to `.use_...` builders
This alleviates unclear properties when the underlying enhancements are
enabled. Now they are enabed when entering `Reedline::read_line` and
disabled when exiting that.

Furthermore allow setting `$env.config.use_kitty_protocol` to have an
effect when toggling during runtime. Previously it was only enabled when
receiving a value from `config.nu`. I kept the warning code there to not
pollute the log. We could move it into the REPL-loop if desired

Not sure if we should actively block the enabling of `bracketed_paste`
on Windows. Need to test what happens if it just doesn't do anything we
could remove the `cfg!` switch. At least for WSL2 Windows Terminal
already supports bracketed paste. `target_os = windows` is a bad
predictor for `conhost.exe`.

Depends on nushell/reedline#659
(pointing to personal fork)

Closes nushell#10982
Supersedes nushell#10998
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.

Pasting with bracketed_paste creates escape codes that affect some programs
4 participants