Skip to content

Rectable selection fixes - #452

Open
reejk wants to merge 2 commits into
icsharpcode:masterfrom
reejk:rectable-selection-tab
Open

Rectable selection fixes#452
reejk wants to merge 2 commits into
icsharpcode:masterfrom
reejk:rectable-selection-tab

Conversation

@reejk

@reejk reejk commented Aug 19, 2026

Copy link
Copy Markdown

There is two changes related to rectangular selection with zero width.

1. When pressing Tab, tabulation inserts at selection column like there is multiple cursors #397

2. When pressing Backspace, avoids cursor jumping up and losing lines from selection in result.

PR #425 is also about this problem.

How to reproduce: Replace the text in the Sample with the text below. Select all the semicolons and press Backspace twice. Selection will lose the last line.

Regular text
	{
		Some block
	}
	
void test();
void test();
void test();
void test();
void test();

The root cause is the precision of mathematical calculations. The HeightTree.GetVisualPositionFromNode method returns a number slightly smaller than what TextView.GetVisualLineFromVisualTop expects for the same line.
The totalHeight sum loses precision, and this totalHeight is also the sum of other calculations. The more work you do with the editor, the lower the precision of these calculations. At some point, the rectangular selection may lose all the initially selected lines.

reejk added 2 commits August 19, 2026 16:36
Before this fix, pressing Backspace with zero-length rectangular selection would cause cursor to jump up one line each time Backspace pressed. It's breaks characters deletion.
Root cause - math precision issues in HeightTree.GetVisualPositionFromNode. This fix avoid that math by reading VisualTop from VisualLine.
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.

1 participant