Skip to content

Unexpected Scrolling Behavior in CodeArea when pressing enter at first line #1276

@Symeon94

Description

@Symeon94

Hello,

I'm currently experiencing an issue with CodeArea when using LineNumberFactory. Below, I'll describe the observed behavior, the expected behavior, and my investigation into the issue.

Observed Behavior

When CodeArea contains enough lines to require a vertical scroll bar:

  1. If the caret is positioned at the very first character (scrolled to the top) and I press Enter, a new line is added, and the view scrolls down, making line 2 the top line.
  2. Pressing Enter again keeps line 2 at the top, while newly added empty lines appear at the top.

Expected Behavior

I have noticed that this behavior is caused by LineNumberFactory. Without the line number factory:

  • The second Enter press shifts line 3 to the top.
  • Subsequent presses continue moving lines 4, 5, 6, etc., to the top.

The behavior I am trying to achieve is no scrolling at all in this specific case. Ideally:

  • If the view is scrolled to the top-most position and the caret is placed on the first line, pressing Enter should not scroll. Line 1 should remain at the top.

Investigation

I am currently analyzing the code to determine where this scrolling behavior occurs when pressing Enter. My goal is either to fix the behavior or implement a workaround for my use case.

I thought someone here might have insights into the relevant section of the code, which would help save time in pinpointing the cause.

If I find additional details, I will update this issue accordingly.

Thank you in advance!

Best regards,
Syméon

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions