Skip to content

feat: add better prompt marker in REPL's multi-line mode #1818

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

Closed
wants to merge 1 commit into from

Conversation

Snehil-Shah
Copy link
Member

Resolves #1763

Description

What is the purpose of this pull request?

This pull request:

  • adds a better prompt when adding a new line to align with the rest of the code block

after

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@kgryte kgryte added Enhancement Issue or pull request for enhancing existing functionality. Needs Review A pull request which needs code review. REPL Issue or pull request specific to the project REPL. labels Mar 11, 2024
@@ -26,6 +26,11 @@ var repeat = require( '@stdlib/string/repeat' );
var leadingWhitespaceRegExp = require( './regexp_leading_whitespace.js' );


// VARIABLES //

var BASE_PROMPT = '...: ';
Copy link
Member

Choose a reason for hiding this comment

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

How would this work when a user provides a custom prompt? This assumes that the prompt is of the form In [%d]:, but that is not necessarily the case. See https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/repl#repl-options-.

Copy link
Member

Choose a reason for hiding this comment

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

E.g., the prompt could be changed to > or $ or something else entirely. In which case, this implementation is making an assumption about the form of the prompt which is not guaranteed to be true.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, I messed up there. One solution can be, the prompt can just consist of spaces/dots the length of the input prompt, the lines would still align , there would be no ...: in the prompt

Copy link
Member Author

Choose a reason for hiding this comment

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

@kgryte something like this:

image

Copy link
Member

Choose a reason for hiding this comment

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

I think this returns us to whether a continuation prompt is necessary. For example, if we support SHIFT+ENTER or some other modifier, then

In [5]:
function func() {
	console.log( 'hello world' );
}

should be possible which achieves alignment, without requiring special prompt handling or the loss of terminal columns with unused whitespace. For the latter in particular, while some terminal applications are good in handling text overflow, others are not, thus making horizontal real estate something of a precious commodity. If we followed IPython and provided a continuation prompt which indents based on the parent prompt, we limit full use of all possible real estate.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense.. I'll close this issue and PR👍

@kgryte kgryte added the Needs Discussion Needs further discussion. label Mar 11, 2024
@Planeshifter Planeshifter removed the Needs Review A pull request which needs code review. label Mar 26, 2024
@Snehil-Shah Snehil-Shah deleted the repl-prompt branch April 26, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Issue or pull request for enhancing existing functionality. Needs Discussion Needs further discussion. REPL Issue or pull request specific to the project REPL.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: add prompt marker to make multi-line code more readable in the REPL
3 participants