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

[Bug]: Unexpected spaces and cursor positioning in custom prompt #285

Closed
DavisRayM opened this issue Dec 15, 2023 · 2 comments
Closed

[Bug]: Unexpected spaces and cursor positioning in custom prompt #285

DavisRayM opened this issue Dec 15, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@DavisRayM
Copy link

What went wrong?

Whenever a new line char is used within the styled! macro it ends up adding some additional spaces(attached image) to the prompt while the cursor is placed at the beginning of the new line.

Using this custom prompt left function:

let git_branch = line_ctx
    .ctx
    .state
    .get::<DirParseState>()
    .and_then(|s| s.get_module_metadata::<Git>("git"))
    .map(|g| format!(" {}", g.branch));

if let Some(branch) = git_branch {
    styled!(@(blue, bold)top_pwd(), " on ", @(blue, bold)branch, "\n", "> ")
} else {
    styled!(@(blue, bold)top_pwd(), " > ")
}

I was expecting the prompt to look like:

<dir> on <branch_info>
>

Screenshot from 2023-12-15 00-47-11

@DavisRayM DavisRayM added the bug Something isn't working label Dec 15, 2023
@MrPicklePinosaur
Copy link
Owner

I believe that prompt has no concept of newlines currently. Will look into this

@nithinmuthukumar
Copy link
Collaborator

Resolved by #287

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

No branches or pull requests

3 participants