Fix wrong given name disambiguation after editing author for citeproc-js
Closes #2870
This commit is contained in:
parent
4e1754b960
commit
a4eafd0307
2 changed files with 31 additions and 0 deletions
|
@ -1038,6 +1038,10 @@ Zotero.Integration.Session.prototype.updateFromDocument = Zotero.Promise.corouti
|
|||
this.progressBar.start();
|
||||
if (forceCitations) {
|
||||
this.regenAll = true;
|
||||
// See Session.restoreProcessorState() for a comment
|
||||
if (!Zotero.Prefs.get('cite.useCiteprocRs')) {
|
||||
this.reload = true;
|
||||
}
|
||||
}
|
||||
yield this._processFields();
|
||||
try {
|
||||
|
@ -2175,6 +2179,12 @@ Zotero.Integration.Session.prototype.restoreProcessorState = function() {
|
|||
citations.push(this.citationsByIndex[i]);
|
||||
}
|
||||
}
|
||||
if (!Zotero.Prefs.get('cite.useCiteprocRs')) {
|
||||
// Due to a bug in citeproc-js there are disambiguation issues after changing items in Zotero library
|
||||
// and rebuilding the processor state, so we reinitialize the processor altogether
|
||||
let style = Zotero.Styles.get(this.data.style.styleID);
|
||||
this.style = style.getCiteProc(this.data.style.locale, this.outputFormat, this.data.prefs.automaticJournalAbbreviations);
|
||||
}
|
||||
this.style.rebuildProcessorState(citations, this.outputFormat, uncited);
|
||||
}
|
||||
|
||||
|
|
|
@ -938,6 +938,27 @@ describe("Zotero.Integration", function () {
|
|||
assert.isTrue(displayDialogStub.lastCall.args[0].includes('editBibliographyDialog'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#refresh', function() {
|
||||
var docID = this.fullTitle();
|
||||
it ('should properly disambiguate author after editing in the database', async function () {
|
||||
let testItem1 = await createDataObject('item', {libraryID: Zotero.Libraries.userLibraryID});
|
||||
testItem1.setField('title', `title1`);
|
||||
testItem1.setCreator(0, {creatorType: 'author', firstName: "Foo", lastName: "Bar"});
|
||||
testItem1.setField('date', '2022-01-01');
|
||||
let testItem2 = await createDataObject('item', {libraryID: Zotero.Libraries.userLibraryID});
|
||||
testItem2.setField('title', `title2`);
|
||||
testItem2.setCreator(0, {creatorType: 'author', firstName: "Foo", lastName: "Bar"});
|
||||
testItem2.setField('date', '2022-01-01');
|
||||
setAddEditItems([testItem1, testItem2]);
|
||||
await initDoc(docID);
|
||||
await execCommand('addEditCitation', docID);
|
||||
assert.equal(applications[docID].doc.fields[0].text, '(Bar, 2022a, 2022b)');
|
||||
testItem2.setCreator(0, {creatorType: 'author', firstName: "Foo F", lastName: "Bar"});
|
||||
await execCommand('refresh', docID);
|
||||
assert.equal(applications[docID].doc.fields[0].text, '(F. Bar, 2022; F. F. Bar, 2022)');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("DocumentData", function() {
|
||||
|
|
Loading…
Reference in a new issue