@@ -62,6 +62,7 @@ public class PreviewPanel extends ScrollPane implements SearchQueryHighlightList
6262 private final KeyBindingRepository keyBindingRepository ;
6363
6464 private String previewStyle ;
65+ private CitationStyle citationStyle ;
6566 private final String defaultPreviewStyle = "Preview" ;
6667 private Optional <BasePanel > basePanel = Optional .empty ();
6768
@@ -224,13 +225,14 @@ private void updateLayout(PreviewPreferences previewPreferences, boolean init) {
224225 String style = previewPreferences .getCurrentPreviewStyle ();
225226 if (previewStyle == null ) {
226227 previewStyle = style ;
228+ CitationStyle .createCitationStyleFromFile (style ).ifPresent (cs -> citationStyle = cs );
227229 }
228230 if (basePanel .isPresent () && !previewStyle .equals (style )) {
229231 if (CitationStyle .isCitationStyleFile (style )) {
230232 layout = Optional .empty ();
231233 CitationStyle .createCitationStyleFromFile (style )
232- .ifPresent (citationStyle -> {
233- basePanel . get (). getCitationStyleCache (). setCitationStyle ( citationStyle ) ;
234+ .ifPresent (cs -> {
235+ citationStyle = cs ;
234236 if (!init ) {
235237 basePanel .get ().output (Localization .lang ("Preview style changed to: %0" , citationStyle .getTitle ()));
236238 }
@@ -299,6 +301,9 @@ public void update() {
299301 .doLayout (entry , databaseContext .getDatabase ())));
300302 setPreviewLabel (sb .toString ());
301303 } else if (basePanel .isPresent () && bibEntry .isPresent ()) {
304+ if (citationStyle != null && !previewStyle .equals (defaultPreviewStyle )) {
305+ basePanel .get ().getCitationStyleCache ().setCitationStyle (citationStyle );
306+ }
302307 Future <?> citationStyleWorker = BackgroundTask
303308 .wrap (() -> basePanel .get ().getCitationStyleCache ().getCitationFor (bibEntry .get ()))
304309 .onRunning (() -> {
0 commit comments