Skip to content

StyledText: selecting larger number of rows gets very slow #3523

Description

@tmssngr

Describe the bug
The more lines are covered with block selection, the slower everything gets.

To Reproduce
Run this snippet:

import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class StyledTextBlockSelectionTest {

	public static void main(String[] args) {
		final Display display = new Display();

		final Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		final StyledText st = new StyledText(shell, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
		final StringBuilder buffer = new StringBuilder();
		for (int i = 0; i < 200; i++) {
			buffer.append("line " + i + "\n");
		}
		st.setText(buffer.toString());
		st.setBlockSelection(true);

		shell.setSize(800, 400);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}

		display.dispose();
	}
}
  • hold Shift and Cursor down
    -> The first dozens of lines, it works normally fast, then around 50 selected lines it gets noticeable slower, at 150 it gets unusable slow.

Expected behavior
It should continue selecting the lines as quick as with normal selection

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    Tested on Windows 11, but as this control is self-drawn, it likely should reproduce on other platforms

Workaround (or) Additional context
No known workaround.

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