Skip to content

password input cursor advances every 2 characters instead of 1 #163

Closed

Description

@adem482p

when connecting to a new WiFi network, the program prompts for input using an input box. the cursor movement however isn't correct. instead of advancing after each character it advances after each two characters.

this bug is purely visual, it doesn't affect correctness.

Activity

  1. adem482p commented on Oct 3, 2026

    @adem482p
    ContributorAuthor

    I believe this is the relevant code:

    let pad_left = if inner_width > pass_len {
    inner_width.saturating_sub(pass_len) / 2
    } else {
    0
    };
    let visual_cursor = self.passphrase.visual_cursor().min(pass_len);
    let x_in_inner = pad_left + visual_cursor;
    let cursor_x = passkey_area.x + 1 + x_in_inner as u16;

    Per my quick printf debugging:

    let pad_left = if inner_width > pass_len {
        inner_width.saturating_sub(pass_len) / 2
    } else {
        0
    };
    
    let visual_cursor = self.passphrase.visual_cursor().min(pass_len);
    
    let x_in_inner = pad_left + visual_cursor;
    
    let cursor_x = passkey_area.x + 1 + x_in_inner as u16;
    
    +log::debug!("pass_len: {pass_len}");
    +log::debug!("pad_left: {pad_left}");
    +log::debug!("visual_cursor: {visual_cursor}");
    +log::debug!("x_in_inner: {x_in_inner}");
    +log::debug!("cursor_x: {cursor_x}");
    +log::debug!("");
    pass_len pad_left visual_cursor x_in_inner cursor_x
    0 33 0 33 38
    1 32 1 33 38
    2 32 2 34 39
    3 31 3 34 39
    4 31 4 35 40
    5 30 5 35 40
    6 30 6 36 41
    7 29 7 36 41
    8 29 8 37 42
  2. adem482p commented on Oct 3, 2026

    @adem482p
    ContributorAuthor

    After thinking about this, i initially thought this can't be solved as long as text remains centered in the input box: centered text has to snap to terminal cells, text can't shift by a half a cell to stay centered on odd lengths, so it instead shifts a whole cell every other character. so since it takes two characters for the text cells to shift, the cursor has to also advance every other character to stay in sync.

    i wasn't wrong, it's true that the cursor would have to move every other character. But i realized that the issues isn't really that "the cursor advances every 2 characters instead of 1", that is completely fine. The user (me) doesn't really notice changes in the absolute position of the cursor. what the user notices is the position of the cursor relative to the text he/she is typing, they expect the interaction between text and cursor to be familiar !

    The solution is simple: text and cursor should take turns shifting, that way the text does shift every other character and the cursor does shift every other character (necessary constraints of centering).

    Whenever the user types a character, the text shifts or stays where it is. if the text shift, the cursor stays in place, if the text doesn't shift then the cursor shifts to covey movement.

    Old behavior

    video.mp4

    New behaviour

    video.mp4
  3. pythops commented on Oct 3, 2026

    @pythops
    Owner

    this PR should fix it #164
    can you give it a try 🙏 ?

  4. adem482p commented on Oct 3, 2026

    @adem482p
    ContributorAuthor

    my bad ! i saw that the issue tracker is empty and i assumed the bug wasn't being worked on.

    can you give it a try 🙏

    yup that fixes it!

  5. added a commit that references this issue on Oct 3, 2026
    d145385
  6. added a commit that references this issue on Oct 4, 2026
    0bd0687
  7. adem482p commented on Oct 4, 2026

    @adem482p
    ContributorAuthor

    I am reopening the issue because the cursor is still broken when the terminal width is under 79 cells and is even.

    The fix in #164 was a workaroud. it didn't fix the underlying problem. #165 did cursor calculation correctly, i rebased it on latest main and patched it to match the behavior you intended in #164, however because github doesn't track commits into a branch of a closed pull request, i had to reopen the branch as a new pull request #167

  8. added a commit that references this issue on Oct 25, 2026
    992b500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions