Skip to content

Horizontal scrolling in multi-cursor selection #5836

Open
@matthieu-m

Description

@matthieu-m

Describe the bug

Multi-cursor selection is very helpful in selecting a large swath of text, especially while ignoring fixed-size prefix on each line, and it's great that Ace supports it.

There is currently a "strange" behavior with regard to horizontal scrolling when using multi-cursor selections and lines that are too long to fit in the window, as can be seen in the following recording by @shepmaster:

Image

In short, once the pointer is outside (on the right) the editor window, the editor window scrolls horizontally to display the cursor of the line the pointer is at. Moving the pointer up & down can therefore cause the editor to see-saw.

This makes it hard to both select all the desired lines & check that the content of all long lines has been selected as expected, when the last line is short.

Expected Behavior

Unclear.

For block selection, the pointer movement is:

  1. Select all lines (moving the pointer from first to last line, or last to first line).
  2. Then move the pointer right until all has been selected.

Knowing when "all has been selected" requires viewing the content, and thus requires the editor window to scroll horizontally to display the furthest right cursor. Even if it has the downside of "hiding" the left side, making it hard to know if all lines are still selected.

Current Behavior

The editor window stops scrolling once the cursor on the first (or last) line is displayed, making it hard to know if the longest lines are fully selected.

Reproduction Steps

Please the see the embedded image, which I shamelessly stole from @shepmaster's comment on the Rust Playground issue:

  1. Create multi-lines content which is large enough that it spills outside the editor window.
  2. Use multi-cursor selection to select multiple lines.
  3. Move the pointer right to select the full content of each line.

Possible Solution

Simplest?

Putting the focus on the right-most cursor when the pointer is moving to the right of the start of the selection, and the left-most cursor when the pointer is moving to the left of the start selection.

It may not be ideal, as it can then be difficult to ensure that all lines are selected.

Ideal?

Ideally one would want to see both the start and end columns of the selection, perhaps a foldable effect -- hiding the middle columns -- would offer the best ergonomics?

Would be quite more complicated, I venture, and it's not clear users would appreciate it either...

Additional Information/Context

No response

Ace Version / Browser / OS / Keyboard layout

Safari on macOS and Firefox 139.0.1 on Windows 11 (Family & Pro)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions