diff --git a/Source/GSAutocompleteWindow.m b/Source/GSAutocompleteWindow.m index a2954499c..b439364b7 100644 --- a/Source/GSAutocompleteWindow.m +++ b/Source/GSAutocompleteWindow.m @@ -26,7 +26,6 @@ #import #import #import -#import "Foundation/NSUndoManager.h" #import "AppKit/NSApplication.h" #import "AppKit/NSBox.h" #import "AppKit/NSEvent.h" @@ -317,7 +316,7 @@ static GSAutocompleteWindow *gsWindow = nil; if ([event window] != self) { [self updateTextViewWithMovement: NSCancelTextMovement - isFinal: YES]; + isFinal: NO]; break; } else @@ -353,7 +352,7 @@ static GSAutocompleteWindow *gsWindow = nil; key == NSLeftArrowFunctionKey) { [self updateTextViewWithMovement: NSCancelTextMovement - isFinal: YES]; + isFinal: NO]; break; } else @@ -383,7 +382,7 @@ static GSAutocompleteWindow *gsWindow = nil; { _stopped = YES; [self updateTextViewWithMovement: NSCancelTextMovement - isFinal: YES]; + isFinal: NO]; } - (void) reloadData @@ -432,28 +431,25 @@ static GSAutocompleteWindow *gsWindow = nil; { NSString *word; - // If this is a cancelling request... - if (movement == NSCancelTextMovement) - { - // Invocation with flag==YES indicates we've inserted at least once - // causing text view to push an undo sequence that we need to undo - // here... - if (flag) - [[_textView undoManager] undo]; - } - else + if (movement != NSCancelTextMovement) { NSInteger rowIndex = [_tableView selectedRow]; word = [[_words objectAtIndex: rowIndex] description]; - [_textView insertCompletion: word - forPartialWordRange: _range - movement: movement - isFinal: flag]; } + else + { + word = _originalWord; + } + + [_textView insertCompletion: word + forPartialWordRange: _range + movement: movement + isFinal: flag]; // Release _words and _originalWords if // autocomplete is final or canceled. - if ((flag) || (movement == NSCancelTextMovement) ) + if ( (flag) || + (movement == NSCancelTextMovement) ) { ASSIGN(_originalWord, nil); ASSIGN(_words, nil); diff --git a/Source/NSTextView.m b/Source/NSTextView.m index 67e713f3e..41e95a4e7 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -2767,7 +2767,7 @@ TextDidEndEditing notification _without_ asking the delegate [undo registerUndoWithTarget: _textStorage selector: @selector(_undoTextChange:) object: undoObject]; - if (isTyping || _tf.isAutoCompleting) + if (isTyping) // || _tf.isAutoCompleting) _undoObject = undoObject; else RELEASE(undoObject);