Skip to content
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
18 changes: 17 additions & 1 deletion src/modules/quicktextParser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,23 @@ export class QuicktextParser {
includeRemote: false,
searchString: states['TO'].data['email'][aIndex].toLowerCase()
})
let card = cards.find(c => c.type == "contact");

let email = states['TO'].data['email'][aIndex].toLowerCase();

// Prefer an exact email address match.
// Thunderbird's quickSearch() may return contacts with similar email addresses, so using the first result can select the wrong contact.
let card = cards.find(c =>
c.type == "contact" &&
(
c.properties.PrimaryEmail?.toLowerCase() == email ||
c.properties.SecondEmail?.toLowerCase() == email
)
);

// Fall back to the previous behavior if no exact match is available.
if (!card) {
card = cards.find(c => c.type == "contact");
}

if (card != null) {
// Get directly stored props first.
Expand Down