Skip to content

Move scroll to focus only if it is out of sight#212

Merged
nakst merged 2 commits into
nakst:masterfrom
serhiyhelp:master
Nov 9, 2025
Merged

Move scroll to focus only if it is out of sight#212
nakst merged 2 commits into
nakst:masterfrom
serhiyhelp:master

Conversation

@serhiyhelp

Copy link
Copy Markdown
Contributor

Before:
When you walk through code the focused line is always in the middle of the view.
After:
The code stays in place and only moves if the focused line leaves the visible area (minus 5 rows of padding).
This way, if you iterate through a small loop the code doesn't jitter back and forth.

@nakst

nakst commented Oct 28, 2025

Copy link
Copy Markdown
Owner

Hi, thanks for the commit.

I think this changed behavior should be controlled by an option setting. For example, I prefer the fixed centering behavior, but I acknowledge not everyone wants this.

You can see examples of the options code here: https://github.com/nakst/gf/blob/master/gf2.cpp#L1276

@serhiyhelp

Copy link
Copy Markdown
Contributor Author

I added option 'center_execution_pointer'. It's value is 'true' by default. It would be better to have the default value be 0, but I couldn't came up with the good name for the opposite property.

@greg7mdp

greg7mdp commented Nov 2, 2025

Copy link
Copy Markdown

It would be better to have the default value be 0, but I couldn't came up with the good name for the opposite property.

You could keep the same name and have bool centerExecutionPointer = false;

@serhiyhelp

Copy link
Copy Markdown
Contributor Author

Oh, I just assumed that Nakst wanted the old behavior to be the default.

@greg7mdp

greg7mdp commented Nov 2, 2025

Copy link
Copy Markdown

Oh my bad I misunderstood your comment. Personally I think it is just fine as is.

Comment thread luigi2.h
int verticalMotionColumn;
bool useVerticalMotionColumn;
bool moveScrollToCaretNextLayout;
bool centerExecutionPointer = true;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Since UICode is allocated with calloc, I don't think this default assignment ever runs. Can you remove it?
Not that it matters because it's overwritten later anyway, but it could be misleading to someone reading the code.

@nakst nakst merged commit a6e5393 into nakst:master Nov 9, 2025
1 check passed
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