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

Fix UI glitches and do not pre-write the answer to questions with the default anwser #6290

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kit-ty-kate
Copy link
Member

@kit-ty-kate kit-ty-kate commented Nov 11, 2024

Queued on top of #6289
This implements what was described in #6289 (review) with the addition of a UI bugfix:

$ opam pin edit ppxlib
Package ppxlib is not pinned. Edit as a new pinning to version 0.33.1~5.3preview? [y/n] y
Press enter to start "vim" (this can be customised by setting EDITOR or OPAMEDITOR)...[WARNING] The opam file didn't pass validation:
  warning 59: url doesn't contain a checksum
Proceed anyway ('no' will re-edit)? [y/n] 

In this example you can see the Press enter ... line is missing the end of line character. This happens because OpamConsole.pause (used to write this line) uses short_user_input with ~default:"", but this function wasn't made to have its default be anything but a string of length 1 in interactive mode. This is marked evident as the prompt subfunction will move the cursor left then remove one character, which happens to be the issue here.

@kit-ty-kate kit-ty-kate added this to the 2.4.0~alpha1 milestone Nov 11, 2024
@rjbou rjbou self-requested a review November 12, 2024 16:24
@kit-ty-kate kit-ty-kate force-pushed the fix-opamconsole-pause branch from 668b1b4 to 57cf486 Compare November 20, 2024 15:55
@@ -824,12 +824,13 @@ let confirm ?(require_unsafe_yes=false) ?(default=true) fmt =
then
(formatted_msg "%sn\n" prompt; false)
else
short_user_input ~prompt ~default:(if default then "y" else "n")
short_user_input ~prompt ~default:' '
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason behind removing the pre-written answer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that it is more standard and expected from regular unix users. All the commands with interactive y/n questions i can think of do this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, i don't have a strong opinion on that :) lgtm

Copy link
Collaborator

@rjbou rjbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR content, lgtm!
I'm wondering if we should split the PR as ther is 2 purposes : the fix and the change (back) of the output of confirm questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants