* Source/NSTextView.m (-scrollRangeToVisible:): Fix to support scrolling

to the empty range at the end of a document (i.e. {[string length], 0}).
This fixes the scrolling when you repeatedly hit RETURN in TextEdit to
create new pages (in wrap to page mode).


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33351 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Eric Wasylishen 2011-06-19 17:52:05 +00:00
parent 2443222fcb
commit 91159aa357
2 changed files with 24 additions and 4 deletions

View file

@ -1,3 +1,10 @@
2011-06-19 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSTextView.m (-scrollRangeToVisible:): Fix to support scrolling
to the empty range at the end of a document (i.e. {[string length], 0}).
This fixes the scrolling when you repeatedly hit RETURN in TextEdit to
create new pages (in wrap to page mode).
2011-06-19 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSButtonCell.m (-setTitle:, -setAttributedTitle:,

View file

@ -2885,11 +2885,24 @@ Scroll so that the beginning of the range is visible.
if (NSMaxRange(aRange) < ourCharRange.location ||
aRange.location > NSMaxRange(ourCharRange))
{
NSTextContainer *tc = [_layoutManager textContainerForGlyphAtIndex:
[_layoutManager glyphRangeForCharacterRange: aRange
actualCharacterRange: NULL].location
// FIXME: The following snippet could be refactored to a method called
// _textContainerForCharacterRange:effectiveCharacterRange:
NSTextContainer *tc;
NSTextView *tv;
NSUInteger glyphIndex = [_layoutManager glyphRangeForCharacterRange: aRange
actualCharacterRange: NULL].location;
// If we are asked to scroll to the empty range at the end of the string,
// adjust the glyph index to be the last glyph, instead of one after the last glyph
if (![_layoutManager isValidGlyphIndex: glyphIndex] &&
[_layoutManager isValidGlyphIndex: glyphIndex - 1])
{
glyphIndex--;
}
tc = [_layoutManager textContainerForGlyphAtIndex: glyphIndex
effectiveRange: NULL];
NSTextView *tv = [tc textView];
tv = [tc textView];
if (tv != self)
{