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

Starship multi-line prompt doesn't play nice with resizes #36

Closed
imsnif opened this issue Nov 10, 2020 · 1 comment
Closed

Starship multi-line prompt doesn't play nice with resizes #36

imsnif opened this issue Nov 10, 2020 · 1 comment
Assignees
Labels
compatibility Issues with VT/terminal compatibility suspected bug

Comments

@imsnif
Copy link
Member

imsnif commented Nov 10, 2020

I started working on this issue and then realized it's a little bit of a rabbit hole, so I'm going to update on my progress here.

Initial issue:

  • When rendering the prompt in a pane, it renders properly but the cursor is at the beginning of the line rather than two spaces after it.

I fixed this by properly responding to the 'C' csi dispatch. 'C' is "Cursor forward", using the first parameter as the count to move forward. But like with other dispatches, 0 means 1 (just 0 though, 1 also means 1, and 2 means 2... it's fun like that :) ). So I fixed it to treat 0 as one and then the cursor appeared in the right place.

Then it broke when we opened another pane with a "cursor out of bounds". This was because we didn't properly change the cursor position when wrapping lines if its line was already wrapped (this is how starship operates, it doesn't create a new line but rather a new wrap by filling the first line with spaces). So, I fixed that in our line wrapping methods and we now treat it properly.

Now, it crashes when we resize the pane to a smaller size than the first starship line. I'm debugging this now.

@imsnif imsnif added suspected bug compatibility Issues with VT/terminal compatibility labels Nov 10, 2020
@imsnif imsnif self-assigned this Nov 10, 2020
@imsnif
Copy link
Member Author

imsnif commented Nov 10, 2020

So, the last issue happened because when we line wrap and a line had 0 characters (as temporarily happens before the starship prompt re-renders) there was a situation where we created a CanonicalLine with no WrappedFragments in it (bad!). Each CanonicalLine should always have at least one WrappedFragment. So, I fixed this and now all seems to work fine.

There's only one issue left where previously rendered prompts get a little messed up when resizing panes, but similar (and worse) things happen with normal terminal windows, so I'm going to call this a win and leave this for now. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Issues with VT/terminal compatibility suspected bug
Projects
None yet
Development

No branches or pull requests

1 participant