Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复英文联想词多余空格的问题 #965

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions YYText/YYTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1422,14 +1422,11 @@ - (CGRect)_convertRectFromLayout:(CGRect)rect {
/// The caller should make sure the `range` and `text` are valid before call this method.
- (void)_replaceRange:(YYTextRange *)range withText:(NSString *)text notifyToDelegate:(BOOL)notify{
if (NSEqualRanges(range.asRange, _selectedTextRange.asRange)) {
if (notify) [_inputDelegate selectionWillChange:self];
NSRange newRange = NSMakeRange(0, 0);
newRange.location = _selectedTextRange.start.offset + text.length;
_selectedTextRange = [YYTextRange rangeWithRange:newRange];
if (notify) [_inputDelegate selectionDidChange:self];
} else {
if (range.asRange.length != text.length) {
if (notify) [_inputDelegate selectionWillChange:self];
NSRange unionRange = NSIntersectionRange(_selectedTextRange.asRange, range.asRange);
if (unionRange.length == 0) {
// no intersection
Expand Down Expand Up @@ -1462,15 +1459,16 @@ - (void)_replaceRange:(YYTextRange *)range withText:(NSString *)text notifyToDel
_selectedTextRange = [YYTextRange rangeWithRange:newRange];
}
}
_selectedTextRange = [self _correctedTextRange:_selectedTextRange];
if (notify) [_inputDelegate selectionDidChange:self];
}
}
if (notify) [_inputDelegate selectionWillChange:self];
if (notify) [_inputDelegate textWillChange:self];
NSRange newRange = NSMakeRange(range.asRange.location, text.length);
[_innerText replaceCharactersInRange:range.asRange withString:text];
[_innerText yy_removeDiscontinuousAttributesInRange:newRange];
_selectedTextRange = [self _correctedTextRange:_selectedTextRange];
if (notify) [_inputDelegate textDidChange:self];
if (notify) [_inputDelegate selectionDidChange:self];
}

/// Save current typing attributes to the attributes holder.
Expand Down