Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.46k stars 948 forks source link

Inconsistent format of line endings in left prompt #1266

Open romkatv opened 5 years ago

romkatv commented 5 years ago

This is in master.

Config:

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir newline background_jobs newline dir_writable)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true

Actual behavior:

actual

Unexpected behavior:

  1. In the first prompt the second line doesn't have a triangle at the end, while the third line does. Note that both of these lines are otherwise empty.
  2. In the third prompt the second line has an unfilled triangle at the end, while the third line has it filled.

Expected behavior: All lines have consistent formatting of the trailing triangle.

expected

FYI: The expected screenshot is from Powerlevel10k.

Syphdias commented 5 years ago

While I agree the background_jobs ending is wrong, I would argue the extra triangle on the second line is not intended. I think empty lines should be "empty".

It would look like this: image

Would this behavior acceptable?

romkatv commented 5 years ago

Would this behavior acceptable?

This is a product decision, so it's your call.

As a user, I think of the Powerlevel9k prompt as composed of multiple powerlines. I expect all powerlines to have consistent rendering. In your suggestion powerlines with segments are rendered consistently regardless of their position, but powerlines without segments have different rendering depending on their position. If you suggested to never never display the triangle for powerlines without segments, this would be consistent even if somewhat strange.

In addition to the preference for consistency, an empty first line of the prompt is easy to mistake for the output of the previous command. In fact, the only reason why I put dir in the configuration in my bug report is to make it clear on the screenshots where each prompt was. Without dir the rendering produced by Powerlevel9k is even more confusing. Here's an example:

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir_writable newline)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()

weird

It looks like /dev/null had \n in it. Weird, isn't it?

Syphdias commented 5 years ago

You are right in this case it can behave a little bit like P9K_PROMPT_ADD_NEWLINE. I wonder if users might even "abuse" this behavior by adding one or multiple leading newline segments.

I would say, it is intended behavior right/for now... I'll note in my PR and if it is not it can always be changed.

Syphdias commented 5 years ago

I just remembered, my PR will not fix the issue of the wrongly colored triangle (this is already fixed on next). It will actually fix a far worse bug with the last line if the segment is hidden: P9K_LEFT_PROMPT_ELEMENTS=(dir newline background_jobs newline dir_writable) image

romkatv commented 5 years ago

It will actually fix a far worse bug...

At least next is rendering all powerlines consistently. IMO this is preferable to what you propose.

Syphdias commented 5 years ago

Essentially, the bug you opened (weird triangle render) is fixed on next

IMO this is preferable to what you propose

What exactly do you mean?

romkatv commented 5 years ago

There are two ways to render a prompt powerline that doesn't have visible segments.

  1. With a triangle.
  2. Without a triangle.

Powerlevel10k does (1). It print the triangle at the end of every powerline, empty or not. This is IMO the best because it makes it clear where the prompt is. Also, it's the most consistent rendering because there are no conditions -- triangle is always there.

next does (2): it prints a triangle at the end of a powerline if and only if that powerline has visible segments.

If I understand your PR correctly, you propose to render the last powerline in the prompt with algorithm (1) and the rest with algorithm (2). In my opinion this is worse than the other two options.

Note that the triangle isn't a full-prompt-suffix symbol (that would be POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX), so it's not easy to logically justify why the last line always has it while other lines only sometimes do.

I should repeat that this is ultimately your call. When I say "preferable" or "worse", this is merely my opinion as a user. I do like consistency.

Syphdias commented 5 years ago

If I understand your PR correctly, you propose to render the last powerline in the prompt with algorithm (1) and the rest with algorithm (2). In my opinion this is worse than the other two options.

Yes you are right. I adjusted it,now it should be consistent and you can still have a symbol on the last line if you so choose by changing P9K_LEFT_SEGMENT_END_SEPARATOR_ICON.