Rectable selection fixes #452

Open
reejk wants to merge 2 commits from reejk/rectable-selection-tab into master
reejk commented 2026-08-19 11:29:27 -05:00 (Migrated from github.com)

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 https://github.com/icsharpcode/AvalonEdit/issues/397

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

PR https://github.com/icsharpcode/AvalonEdit/pull/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.

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 https://github.com/icsharpcode/AvalonEdit/issues/397 #### 2. When pressing Backspace, avoids cursor jumping up and losing lines from selection in result. PR https://github.com/icsharpcode/AvalonEdit/pull/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.
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'reejk/rectable-selection-tab:reejk/rectable-selection-tab'
git switch 'reejk/rectable-selection-tab'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'master'
git merge --no-ff 'reejk/rectable-selection-tab'
git switch 'reejk/rectable-selection-tab'
git rebase 'master'
git switch 'master'
git merge --ff-only 'reejk/rectable-selection-tab'
git switch 'reejk/rectable-selection-tab'
git rebase 'master'
git switch 'master'
git merge --no-ff 'reejk/rectable-selection-tab'
git switch 'master'
git merge --squash 'reejk/rectable-selection-tab'
git switch 'master'
git merge --ff-only 'reejk/rectable-selection-tab'
git switch 'master'
git merge 'reejk/rectable-selection-tab'
git push origin 'master'
Sign in to join this conversation.
No description provided.