From cf9789581748d7745b8f3255943650f362ca2eae Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Mon, 27 Feb 2006 21:55:25 +0000 Subject: [PATCH] Bug #326280 --> suppression of append-domain autocompletion not working in all cases. Port some seamonkey changes back over to thunderbird. git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@191342 18797224-902f-48f8-a5cc-f745e15eee43 --- .../compose/content/MsgComposeCommands.js | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/mozilla/mail/components/compose/content/MsgComposeCommands.js b/mozilla/mail/components/compose/content/MsgComposeCommands.js index 8a5699f2430..0b1b7255c8e 100644 --- a/mozilla/mail/components/compose/content/MsgComposeCommands.js +++ b/mozilla/mail/components/compose/content/MsgComposeCommands.js @@ -3062,49 +3062,64 @@ function LoadIdentity(startup) function setDomainName() { + var defaultDomain = ""; if (gCurrentIdentity.autocompleteToMyDomain) { var emailAddr = gCurrentIdentity.email; var start = emailAddr.lastIndexOf("@"); - gAutocompleteSession.defaultDomain = emailAddr.slice(start + 1, emailAddr.length); + defaultDomain = emailAddr.slice(start + 1); } + + // If autocompleteToMyDomain is false the defaultDomain is emptied + gAutocompleteSession.defaultDomain = defaultDomain; } function setupAutocomplete() { //Setup autocomplete session if we haven't done so already - if (!gAutocompleteSession) { + if (!gAutocompleteSession) + { gAutocompleteSession = Components.classes["@mozilla.org/autocompleteSession;1?type=addrbook"].getService(Components.interfaces.nsIAbAutoCompleteSession); - if (gAutocompleteSession) { + if (gAutocompleteSession) + { setDomainName(); + + var autoCompleteWidget = document.getElementById("addressCol2#1"); + // When autocompleteToMyDomain is off there is no default entry with the domain + // appended so reduce the minimum results for a popup to 2 in this case. + if (!gCurrentIdentity.autocompleteToMyDomain) + autoCompleteWidget.minResultsForPopup = 2; // if the pref is set to turn on the comment column, honor it here. // this element then gets cloned for subsequent rows, so they should // honor it as well // - try { - if (sPrefs.getBoolPref("mail.autoComplete.highlightNonMatches")) - document.getElementById('addressCol2#1').highlightNonMatches = true; - - if (sPrefs.getIntPref("mail.autoComplete.commentColumn")) { - document.getElementById('addressCol2#1').showCommentColumn = true; - } + try + { + if (sPrefs.getBoolPref("mail.autoComplete.highlightNonMatches")) + autoCompleteWidget.highlightNonMatches = true; + + if (sPrefs.getIntPref("mail.autoComplete.commentColumn")) + autoCompleteWidget.showCommentColumn = true; + } catch (ex) { // if we can't get this pref, then don't show the columns (which is // what the XUL defaults to) } - } else { + } else + { gAutocompleteSession = 1; } } - if (!gSetupLdapAutocomplete) { - try { - setupLdapAutocompleteSession(); - } catch (ex) { - // catch the exception and ignore it, so that if LDAP setup - // fails, the entire compose window doesn't end up horked - } + if (!gSetupLdapAutocomplete) + { + try { + setupLdapAutocompleteSession(); + } catch (ex) { + // catch the exception and ignore it, so that if LDAP setup + // fails, the entire compose window doesn't end up horked + } } }