fix(anki): preserve one-sided Senren furigana

This commit is contained in:
2026-08-31 23:48:11 -07:00
parent 6a6af369ec
commit 8eba6d11f9
2 changed files with 23 additions and 2 deletions
@@ -394,7 +394,7 @@ test('Senren merge closes unclosed group spans so later scenes stay siblings', a
assert.equal(openTags, closeTags);
});
test('computeFieldGroupingMergedFields clears SentenceFurigana when either note lacks it', async () => {
test('Kiku merge clears SentenceFurigana when either note lacks it', async () => {
const { collaborator } = createCollaborator();
const merged = await collaborator.computeFieldGroupingMergedFields(
@@ -411,3 +411,21 @@ test('computeFieldGroupingMergedFields clears SentenceFurigana when either note
assert.equal(merged.SentenceFurigana, '');
});
test('Senren merge keeps duplicate SentenceFurigana when the kept field is empty', async () => {
const { collaborator } = createCollaborator({ fieldGroupingProvider: 'senren' });
const merged = await collaborator.computeFieldGroupingMergedFields(
300,
200,
makeNote(300, {
SentenceFurigana: '',
}),
makeNote(200, {
SentenceFurigana: 'duplicate furigana',
}),
false,
);
assert.equal(merged.SentenceFurigana, '<span class="group">duplicate furigana</span>');
});
+4 -1
View File
@@ -162,8 +162,11 @@ export class FieldGroupingMergeCollaborator {
if (!existingValue.trim() && !newValue.trim()) continue;
if (keepFieldNormalized === 'sentencefurigana') {
const hasBothValues = existingValue.trim().length > 0 && newValue.trim().length > 0;
const usesSenrenGrouping =
this.deps.getEffectiveSentenceCardConfig().fieldGroupingProvider === 'senren';
mergedFields[keepFieldName] =
existingValue.trim() && newValue.trim()
hasBothValues || usesSenrenGrouping
? this.applyFieldGrouping(
existingValue,
newValue,