mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 23:50:49 +00:00
(-processEditing): Make sure we always give a valid range and delta to the layout managers.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15936 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
68e87b286c
commit
78fc19a490
1 changed files with 27 additions and 0 deletions
|
@ -186,6 +186,7 @@ static NSNotificationCenter *nc = nil;
|
||||||
- (void) processEditing
|
- (void) processEditing
|
||||||
{
|
{
|
||||||
NSRange r;
|
NSRange r;
|
||||||
|
int original_delta;
|
||||||
int i;
|
int i;
|
||||||
unsigned length;
|
unsigned length;
|
||||||
|
|
||||||
|
@ -201,6 +202,7 @@ static NSNotificationCenter *nc = nil;
|
||||||
|
|
||||||
/* Very important: we save the current _editedRange */
|
/* Very important: we save the current _editedRange */
|
||||||
r = _editedRange;
|
r = _editedRange;
|
||||||
|
original_delta = _editedDelta;
|
||||||
length = [self length];
|
length = [self length];
|
||||||
// Multiple adds at the end might give a too long result
|
// Multiple adds at the end might give a too long result
|
||||||
if (NSMaxRange(r) > length)
|
if (NSMaxRange(r) > length)
|
||||||
|
@ -221,6 +223,31 @@ static NSNotificationCenter *nc = nil;
|
||||||
object: self];
|
object: self];
|
||||||
_editCount--;
|
_editCount--;
|
||||||
|
|
||||||
|
/*
|
||||||
|
The attribute fixes might have added or removed characters. We must make
|
||||||
|
sure that range and delta we give to the layout managers is valid.
|
||||||
|
*/
|
||||||
|
if (original_delta != _editedDelta)
|
||||||
|
{
|
||||||
|
if (_editedDelta - original_delta > 0)
|
||||||
|
{
|
||||||
|
r.length += _editedDelta - original_delta;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (original_delta - _editedDelta > r.length)
|
||||||
|
{
|
||||||
|
r.length = 0;
|
||||||
|
if (r.location > [self length])
|
||||||
|
r.location = [self length];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r.length += _editedDelta - original_delta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calls textStorage:edited:range:changeInLength:invalidatedRange: for
|
* Calls textStorage:edited:range:changeInLength:invalidatedRange: for
|
||||||
* every layoutManager.
|
* every layoutManager.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue