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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion crates/nu-cli/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,12 @@ pub fn evaluate_repl(
}
}

// We should not have bracketed paste enabled during the execution
// of a child.
if engine_state.get_config().bracketed_paste {
let _ = line_editor.disable_bracketed_paste();
}

eval_source(
engine_state,
stack,
Expand All @@ -596,8 +602,9 @@ pub fn evaluate_repl(
PipelineData::empty(),
false,
);

// Ensure bracketed paste is enabled again
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

let _ = line_editor.enable_bracketed_paste();
}
}
Expand Down