Skip to content

Formspec: Measure length of PasswordChar in pwdfield[] to avoid scrolling early#16847

Open
CrazyladMT wants to merge 2 commits intoluanti-org:masterfrom
CrazyladMT:fix-pwdfield-character-thing
Open

Formspec: Measure length of PasswordChar in pwdfield[] to avoid scrolling early#16847
CrazyladMT wants to merge 2 commits intoluanti-org:masterfrom
CrazyladMT:fix-pwdfield-character-thing

Conversation

@CrazyladMT
Copy link
Contributor

@CrazyladMT CrazyladMT commented Jan 15, 2026

Fixes #9368

Note

I used GPT-5 to assist with these changes.

To do

This PR is Ready for Review.

How to test

  1. navigate to the 'Join Game' tab in the main menu
  2. type "i" a bunch
  3. now delete the "i"s and type the same amount of "M" or "W"
  4. observe that it no longer scrolls early with wide characters and scrolls only when it fills up with the PasswordChar "*"
Screenshot From 2026-01-14 22-58-19

@sfan5 sfan5 added Bugfix 🐛 PRs that fix a bug Formspec labels Jan 15, 2026
@CrazyladMT CrazyladMT requested a review from SmallJoker January 15, 2026 19:48
// get cursor area
u32 cursorWidth = font->getDimension(CursorChar.c_str()).Width;
core::stringw *txtLine = hasBrokenText ? &BrokenText[cursLine] : &Text;
core::stringw *txtLine = (hasBrokenText || PasswordBox) ? &BrokenText[cursLine] : &Text;
Copy link
Contributor

Choose a reason for hiding this comment

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

question, why in draw we have WordWrap and not there ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll have more time after this weekend to apply changes if needed, but in the meantime, it already checks for WordWrap here, right?

const bool hasBrokenText = MultiLine || WordWrap;

This change was suggested by SmallJoker in his first review (#16847 (comment))

const s32 hlineCount = ml ? getLineFromPos(realmend) - hlineStart + 1 : 1;
const s32 lineCount = ml ? BrokenText.size() : 1;

core::stringw *txtLine = (PasswordBox || WordWrap || MultiLine) ? &BrokenText[0] : &Text;
Copy link
Member

Choose a reason for hiding this comment

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

This needs updating inside the loop to render multi-line text correctly. See previous L817 and L818.

Comment on lines +1459 to +1461
if (PasswordBox && BrokenText.empty()) {
breakText();
}
Copy link
Member

@SmallJoker SmallJoker Jan 23, 2026

Choose a reason for hiding this comment

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

Why's the function call needed? inputString and processKey already break the text.

@CrazyladMT
Copy link
Contributor Author

Seems there are some things that need to be fixed...

I'm a little busy with other things at the moment, but I'll see what I can do soon... though some help would be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix 🐛 PRs that fix a bug Formspec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FormSpec password fields use hidden text width, not "*" width

5 participants