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 for #1151 - Add line numbers and current line marker to secondary prompt #1152

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

Conversation

bamcgill
Copy link

This PR aims to add line numbering to the secondary prompt, and the current edit line will also be marked with an asterisk (*).

This is the behavior before the change:

before.mov

And this is the new behavior:

after.mov

@bamcgill
Copy link
Author

@gnodet Here is a first pass as one of our fixes. @Eraoui909 has prepped this from the first change we want.

@gnodet
Copy link
Member

gnodet commented Jan 13, 2025

Does the * follows the cursor if you move one line up using left arrow keys for example ?

@Eraoui909
Copy link

Hey @gnodet
Right now, the * does not follow the left/right arrow keys

@bamcgill
Copy link
Author

Actually, @Eraoui909 the * will follow the left and right arrows if the left/right arrow make cursor go past a row boundary. Technically it follows the cursor line.

@Eraoui909
Copy link

Hey @gnodet,
I've fixed the astrike movement.
Here is how it looks now:

Screen.Recording.2025-01-14.at.10.22.15.PM.mov

@@ -4176,6 +4177,16 @@ private AttributedString expandPromptPattern(String pattern, int padToWidth, Str
case 'N':
sb.append(getInt(LINE_OFFSET, 0) + line);
break decode;
case 'C':
Copy link
Member

Choose a reason for hiding this comment

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

Why this new C option ? it seems to me that setting LINE_OFFSET to 1 would achieve the same ?

Choose a reason for hiding this comment

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

The C option used to handle this pattern %5P %C%* for numbering the new secondary prompt lines

sb.append(getInt(LINE_OFFSET, 0) + (line + 1));
break decode;
case '*':
if (getCurrentLineNo(this.currentLines) == line) {
Copy link
Member

Choose a reason for hiding this comment

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

The currentLine should be computed once and passed as an argument to this method.

Choose a reason for hiding this comment

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

I don't think we can do this because, in a secondary prompt, the number of lines may change with each new user input. Therefore, I need to ensure that I always get the updated number of lines.

@@ -4277,6 +4303,7 @@ private AttributedString insertSecondaryPrompts(
buf.setLength(0);
}
int line = 0;
this.currentLines = lines;
Copy link
Member

Choose a reason for hiding this comment

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

if we compute the currentLine easier, maybe we can store only that information instead of the list of lines ?

Choose a reason for hiding this comment

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

So, I'll compute directly the currentLine.
Thanks!

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

Successfully merging this pull request may close these issues.

3 participants