Skip to content

Conversation

@nullst
Copy link
Contributor

@nullst nullst commented Dec 4, 2025

Description:

As currently coded, the Entry widget calls entryContentRenderer.moveCursor() every time entryContentRenderer.Refresh() is invoked. In turn, moveCursor() always calls ensureCursorVisible(). In other words, whenever the entry content renderer refreshes, the contents of the entry are automatically scrolled to put the current cursor position on screen. This may cause a multiline entry to scroll back to the cursor position even when this is not warranted -- as demonstrated in #6042, unfocusing or focusing an entry may lead to unexpected scroll jumps.

I have changed the code of the moveCursor function so that it only calls ensureCursorVisible when necessary instead of every time (my superficial understanding is that the moveCursor function should probably be renamed to refreshCursor or something like that based on how it is used elsewhere). Here "when necessary" is defined "whenever a piece of code (potentially) changes entry.CursorRow or entry.CursorColumn.

Fixes #6042 .

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

@nullst nullst marked this pull request as draft December 4, 2025 22:06
@nullst nullst marked this pull request as ready for review December 4, 2025 22:19
@nullst
Copy link
Contributor Author

nullst commented Dec 4, 2025

The remaining failing test is unlikely to be related to my code (on my local laptop fyne tests always fail, github runners appear to be slightly more robust...).

I have reintroduced the scrolling behavior when the application changes the wrapping type or the scroll type of the entry. I am not sure if this is truly what I would expect as a user, but since the current behavior is codified into tests, I have chosen the path of the least resistance. I also don't really know what should happen when the entry is resized (should it automatically scroll to keep the cursor in the visible part of the text? Maybe "yes if the cursor has been visible, no if it was not"?).

@coveralls
Copy link

Coverage Status

coverage: 61.017% (+0.04%) from 60.976%
when pulling d34bcfe on nullst:nullst-fix-cursor
into f400fa2 on fyne-io:develop.

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.

2 participants