Should fix the problems with dirty selection left-overs when editing and also
other situations. Basically, I made DeleteText() adjust the selection according to the deleted range. Some places where DeleteText() was called forgot to adopt the selection. Other places adopted the selection. Maybe some of those could be removed now, but some also change fClickOffset, so I just left them as they are. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30076 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
bedfcd63af
commit
78772ca58c
@ -3037,6 +3037,28 @@ BTextView::DeleteText(int32 fromOffset, int32 toOffset)
|
||||
|
||||
// remove any style runs that have been obliterated
|
||||
fStyles->RemoveStyleRange(fromOffset, toOffset);
|
||||
|
||||
// adjust the selection accordingly, assumes fSelEnd >= fSelStart!
|
||||
int32 range = toOffset - fromOffset;
|
||||
if (fSelStart >= toOffset) {
|
||||
// selection is behind the range that was removed
|
||||
fSelStart -= range;
|
||||
fSelEnd -= range;
|
||||
} else if (fSelStart >= fromOffset && fSelEnd <= toOffset) {
|
||||
// the selection is within the range that was removed
|
||||
fSelStart = fSelEnd = fromOffset;
|
||||
} else if (fSelStart >= fromOffset && fSelEnd > toOffset) {
|
||||
// the selection starts within and ends after the range
|
||||
// the remaining part is the part that was after the range
|
||||
fSelStart = fromOffset;
|
||||
fSelEnd = fromOffset + fSelEnd - toOffset;
|
||||
} else if (fSelStart < fromOffset && fSelEnd < toOffset) {
|
||||
// the selection starts before, but ends within the range
|
||||
fSelEnd = fromOffset;
|
||||
} else if (fSelStart < fromOffset && fSelEnd >= toOffset) {
|
||||
// the selection starts before and ends after the range
|
||||
fSelEnd -= range;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3341,7 +3363,6 @@ BTextView::_HandleDelete()
|
||||
Highlight(fSelStart, fSelEnd);
|
||||
|
||||
DeleteText(fSelStart, fSelEnd);
|
||||
|
||||
fClickOffset = fSelEnd = fSelStart;
|
||||
|
||||
_Refresh(fSelStart, fSelEnd, true, true);
|
||||
|
Loading…
Reference in New Issue
Block a user