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(cli): Handle overflow in promptSecret #6318

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

cosmastech
Copy link

@cosmastech cosmastech commented Dec 30, 2024

To close #6306

There is an issue where backspacing characters from multiple lines will not move the cursor back to the original lines. I welcome any input on how to improve this, or if it's necessary.

deno-promptSecret_2.mov

@CLAassistant
Copy link

CLAassistant commented Dec 30, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the cli label Dec 30, 2024
@cosmastech cosmastech changed the title Handle overflow in promptSecret fix(cli): Handle overflow in promptSecret Dec 30, 2024
Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.36%. Comparing base (9b86f0f) to head (488f223).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6318   +/-   ##
=======================================
  Coverage   96.36%   96.36%           
=======================================
  Files         547      547           
  Lines       41731    41755   +24     
  Branches     6325     6331    +6     
=======================================
+ Hits        40212    40238   +26     
+ Misses       1478     1476    -2     
  Partials       41       41           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cosmastech cosmastech marked this pull request as ready for review December 30, 2024 19:17
@cosmastech cosmastech requested a review from kt3k as a code owner December 30, 2024 19:17
@kt3k
Copy link
Member

kt3k commented Jan 4, 2025

Thanks for the PR. This looks much better than the current state!

However if I filled the first 2 lines and then deleted the entire 2nd line, then the initial prompt part was duplicated again.. Could you take a look at this point as well?

(I guess we can use 'Cursor Control' codes to remove the entire prompt + masks https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#cursor-controls)

@cosmastech
Copy link
Author

cosmastech commented Jan 4, 2025

Thanks for the PR. This looks much better than the current state!

However if I filled the first 2 lines and then deleted the entire 2nd line, then the initial prompt part was duplicated again.. Could you take a look at this point as well?

(I guess we can use 'Cursor Control' codes to remove the entire prompt + masks https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#cursor-controls)

Absolutely!

Two thoughts:

  1. Would it be beneficial to create a "cliWindow" utility that sets a height/width and handles overflow? Seems like it could be useful more generally. I think it may be necessary to achieve this, because
  2. How do we handle screen resizes? We have to know the former width so we can figure out how many lines to move back and replace. (This is more of a "I think," as I haven't played around yet)

edit: While I think a CliWindow utility class may be helpful, it's not strictly necessary to close this ticket.

@cosmastech
Copy link
Author

@kt3k I believe your issue is addressed. I've updated the description to include a screen recording of the current implementation.

There's still an issue where resizing the screen after prompting causes undesirable behavior. In order to fix this, we need to keep track of the console size and check it before writing anything to the terminal. Is calling Deno.consoleSize() an expensive operation, or is it safe to do on each character press?

An example of what happens when resizing a terminal window:

deno-promptSecret_with-screen-resize.mov

@cosmastech cosmastech force-pushed the prompt_secret_multiline branch from e507994 to 355515c Compare January 5, 2025 12:54
@cosmastech cosmastech force-pushed the prompt_secret_multiline branch from 355515c to 64a40a9 Compare January 6, 2025 16:33
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.

promptSecret() prints redundant lines for long inputs
3 participants