8000 Don't assume $__fish_git_prompt_char_cleanstate is non-empty by shlemas · Pull Request #7471 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
faho merged 1 commit intofish-shell:masterfrom
shlemas:empty-char-cleanstate
Nov 10, 2020
Merged

Don't assume $__fish_git_prompt_char_cleanstate is non-empty#7471
faho merged 1 commit intofish-shell:masterfrom
shlemas:empty-char-cleanstate

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 70B8
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.

2 participants

0