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

Don't assume $__fish_git_prompt_char_cleanstate is non-empty #7471

Merged
merged 1 commit into from
Nov 10, 2020

Conversation

shlemas
Copy link
Contributor

@shlemas shlemas commented Nov 9, 2020

This fixes the case where an empty "clean state" character
can cause a spurious space character at the end of the git prompt.

Description

I've been trying to integrate fish_git_prompt into a custom prompt and running into minor issues. The first was fixed by discovering the undocumented argument where you can pass in a format string. The second is fixed by this commit. When running the prompt in informative mode with $__fish_git_prompt_char_cleanstate set to an empty string while inside a clean repository, the prompt looks like this:

(master )

Note the spurious space after master. Minor but a bit ugly/annoying. Even when passing in "%s" as the argument to fish_git_prompt and running the result through string trim, the output will still be master with a trailing space, presumably because some color codes are getting in the way of the trim operation. So this commit adds a couple simple checks in and around the informative status function to make sure we aren't echoing spurious output.

Thanks!

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

This fixes the case where an empty "clean state" character
can cause a spurious space character at the end of the git prompt.
@shlemas
Copy link
Contributor Author

shlemas commented Nov 9, 2020

I looked at the test failure but it doesn't appear to be related to my change. Let me know if I'm wrong about that.

@faho
Copy link
Member

faho commented Nov 9, 2020

It's not, Github's macos test machines are just awful, and we need to work out some of the kinks.

(necessary because Travis made their Open-source plan unusable)

@faho faho added this to the fish 3.2.0 milestone Nov 10, 2020
@faho faho merged commit e4b6444 into fish-shell:master Nov 10, 2020
@faho
Copy link
Member

faho commented Nov 10, 2020

Merged, thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants