diff --git a/camino/src/browser/AutoCompleteTextField.mm b/camino/src/browser/AutoCompleteTextField.mm index 5717579e55a6..179d8d43b997 100644 --- a/camino/src/browser/AutoCompleteTextField.mm +++ b/camino/src/browser/AutoCompleteTextField.mm @@ -493,6 +493,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) NSRange range = NSMakeRange(aLocation,[[fieldEditor string] length] - aLocation); if ([fieldEditor shouldChangeTextInRange:range replacementString:aString]) { [[fieldEditor textStorage] replaceCharactersInRange:range withString:aString]; + if (NSMaxRange(range) == 0) // will only be true if the field is empty + [fieldEditor setFont:[self font]]; // wrong font will be used otherwise // Whenever we send [self didChangeText], we trigger the // textDidChange method, which will begin a new search with // a new search string (which we just inserted) if the selection diff --git a/camino/src/browser/BrowserWindowController.mm b/camino/src/browser/BrowserWindowController.mm index 7ddc74181a1d..a91ecc931f42 100644 --- a/camino/src/browser/BrowserWindowController.mm +++ b/camino/src/browser/BrowserWindowController.mm @@ -115,11 +115,22 @@ static NSArray* sToolbarDefaults = nil; ////////////////////////////////////// @interface AutoCompleteTextFieldEditor : NSTextView { + NSFont* mDefaultFont; // will be needed if editing empty field } +- (id)initWithFrame:(NSRect)bounds defaultFont:(NSFont*)defaultFont; @end @implementation AutoCompleteTextFieldEditor +// sets the defaultFont so that we don't paste in the wrong one +- (id)initWithFrame:(NSRect)bounds defaultFont:(NSFont*)defaultFont +{ + if ((self = [super initWithFrame:bounds])) { + mDefaultFont = defaultFont; + } + return self; +} + -(void)paste:(id)sender { NSPasteboard *pboard = [NSPasteboard generalPasteboard]; @@ -132,6 +143,8 @@ static NSArray* sToolbarDefaults = nil; NSRange aRange = [self selectedRange]; if ([self shouldChangeTextInRange:aRange replacementString:newText]) { [[self textStorage] replaceCharactersInRange:aRange withString:newText]; + if (NSMaxRange(aRange) == 0 && mDefaultFont) // will only be true if the field is empty + [self setFont:mDefaultFont]; // wrong font will be used otherwise [self didChangeText]; } // after a paste, the insertion point should be after the pasted text @@ -2129,7 +2142,8 @@ static NSArray* sToolbarDefaults = nil; { if ([anObject isEqual:mURLBar]) { if (!mURLFieldEditor) { - mURLFieldEditor = [[AutoCompleteTextFieldEditor alloc] init]; + mURLFieldEditor = [[AutoCompleteTextFieldEditor alloc] initWithFrame:[anObject bounds] + defaultFont:[mURLBar font]]; [mURLFieldEditor setFieldEditor:YES]; [mURLFieldEditor setAllowsUndo:YES]; }