From 06e1c404bd58e6bb8f5412625f03321dcbe4eb16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Fri, 13 Nov 2020 14:13:27 +0200 Subject: [PATCH] Changes to note insertion for MacWord --- chrome/content/zotero/xpcom/integration.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 20e5684f47..63fd902e4e 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -1371,10 +1371,18 @@ Zotero.Integration.Session.prototype.cite = async function (field) { await citationsByItemIDPromise; let citations = await this._insertCitingResult(fieldIndex, field, io.citation); - // We need to re-update from document because we've inserted multiple fields. - // Don't worry, the field list and info is cached so this triggers no calls to the doc. + if (citations.length > 1) { + // We need to refetch fields because we've inserted multiple. + // This is not super optimal, but you're inserting 2+ citations at the time, + // so that sets it off + var fields = await this.getFields(true); + } + // And resync citations with ones in the doc await this.updateFromDocument(FORCE_CITATIONS_FALSE); for (let citation of citations) { + if (fields) { + citation._field = new Zotero.Integration.CitationField(fields[citation._fieldIndex]); + } await this.addCitation(citation._fieldIndex, await citation._field.getNoteIndex(), citation); } return citations;