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

Strange behavior with multi-line prompts #8911

Open
NfNitLoop opened this issue Apr 17, 2023 · 5 comments
Open

Strange behavior with multi-line prompts #8911

NfNitLoop opened this issue Apr 17, 2023 · 5 comments
Labels
🐛 bug Something isn't working line editor Issues related to reedline

Comments

@NfNitLoop
Copy link

Describe the bug

From a conversation in Discord:

Is this a bug, or me not understanding something about the way prompts work?
let-env PROMPT_INDICATOR = {|| "> " } is the default. But if I change it to:
let-env PROMPT_INDICATOR = {|| "\n> " }
I do get the newline, but the > disappears?
But if I prefix with a space like this, then I get both:
let-env PROMPT_INDICATOR = {|| " \n> " }

How to reproduce

  1. let-env PROMPT_INDICATOR = {|| "\n> " }

Notice that you get a prompt w/ a newline, but no >.

Expected behavior

I expected to have a prompt of "> " on a line by itself. (I prefer my prompts always start at the same indentation, regardless of how deep I am into a random file path.)

Or, if there's some additional behavior going on for the various prompts (ex: if some trimming is going on, or multi-line prompts aren't supported), I'd expect to see that in docs. 😊

Screenshots

Screenshot 2023-04-17 at 8 57 00 AM

Configuration

key value
version 0.78.0
branch
commit_hash
build_os macos-aarch64
build_target aarch64-apple-darwin
rust_version rustc 1.68.2 (9eb3afe9e 2023-03-27) (built from a source tarball)
cargo_version cargo 1.68.1 (6feb7c9cf 2023-03-26)
build_time 2023-04-04 18:47:00 +00:00
build_rust_channel release
features default, zip
installed_plugins

Additional context

No response

@sholderbach sholderbach added 🐛 bug Something isn't working line editor Issues related to reedline labels Apr 17, 2023
@Mehrbod2002
Copy link
Contributor

@sholderbach Can I work on it ?

@amtoine
Copy link
Member

amtoine commented Apr 17, 2023

@sholderbach Can I work on it ?

anyone is welcome to contribute, i'm sure @sholderbach would say "please do so" 😉

@NfNitLoop
Copy link
Author

Oh! I forgot to mention that I'd already tried moving the newline into create_left_prompt by changing its last line to this:

$path_segment + "\n"

… but that newline seemed to get lost (trimmed?). It might be worth checking if whatever is going on with PROMPT_INDICATOR is also happening with the other PROMPT_ variables.

@hyrious
Copy link

hyrious commented Aug 22, 2023

It seems each PROMPT_* variables' last newline character is dropped:

output.map(|mut x| {
// Just remove the very last newline.
if x.ends_with('\n') {
x.pop();
}
if x.ends_with('\r') {
x.pop();
}
x

@maxomatic458
Copy link
Contributor

seems to be the same problem described in nushell/reedline#707

i think this can just be reproduced in reedline, so the issue is probably there somewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working line editor Issues related to reedline
Projects
None yet
Development

No branches or pull requests

6 participants