From 03b96677894d335748c7221861fbd111a8582582 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Mon, 22 Mar 2021 12:12:52 +0100 Subject: [PATCH] Use raw sort field text in note_field_str() ... ... instead of the preprocessed note.sort_field. That means we always have to load the note with fields. --- rslib/src/browser_rows.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rslib/src/browser_rows.rs b/rslib/src/browser_rows.rs index 9d597a81d..903700bb4 100644 --- a/rslib/src/browser_rows.rs +++ b/rslib/src/browser_rows.rs @@ -132,7 +132,10 @@ impl RenderContext { impl<'a> RowContext<'a> { fn new(col: &'a mut Collection, id: CardID, with_card_render: bool) -> Result { let card = col.storage.get_card(id)?.ok_or(AnkiError::NotFound)?; - let note = if with_card_render { + // todo: After note.sort_field has been modified so it can be displayed in the browser, + // we can update note_field_str() and only load the note with fields if a card render is + // necessary (see #1082). + let note = if true { col.storage.get_note(card.note_id)? } else { col.storage.get_note_without_fields(card.note_id)? @@ -295,11 +298,8 @@ impl<'a> RowContext<'a> { } fn note_field_str(&self) -> String { - if let Some(field) = &self.note.sort_field { - field.to_owned() - } else { - "".to_string() - } + let index = self.notetype.config.sort_field_idx as usize; + html_to_text_line(&self.note.fields()[index]).into() } fn template_str(&self) -> Result {