Skip to content

Commit

Permalink
Fix incorrect code block rendering in live preview (#2417)
Browse files Browse the repository at this point in the history
* Revert "Fix inline list rendering in live preview  (#2387)"

This reverts commit 6a6e025.

* Fix inline rendering for lists in live preview

* fix formatting

* Fix incorrect code block rendering

* fix formatting
  • Loading branch information
reply2za authored Feb 22, 2025
1 parent 41c8f3a commit d95f20b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/ui/views/inline-field-live-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ViewUpdate,
WidgetType,
} from "@codemirror/view";
import { InlineField, extractInlineFields, parseInlineValue } from "data-import/inline-field";
import { extractInlineFields, InlineField, parseInlineValue } from "data-import/inline-field";
import { canonicalizeVarName } from "util/normalize";
import { renderCompactMarkdown, renderValue } from "ui/render";
import { DataviewSettings } from "settings";
Expand Down Expand Up @@ -58,7 +58,7 @@ function buildInlineFields(state: EditorState): RangeSet<InlineFieldValue> {
export const inlineFieldsField = StateField.define<RangeSet<InlineFieldValue>>({
create: buildInlineFields,
update(oldFields, tr) {
return tr.docChanged ? buildInlineFields(tr.state) : oldFields;
return buildInlineFields(tr.state);
},
});

Expand Down Expand Up @@ -128,9 +128,7 @@ export const replaceInlineFieldsInLivePreview = (app: App, settings: DataviewSet
if (update.docChanged) {
this.decorations = this.decorations.map(update.changes);
this.updateDecorations(update.view);
} else if (update.selectionSet) {
this.updateDecorations(update.view);
} else if (update.viewportChanged || layoutChanged) {
} else if (update.selectionSet || update.viewportChanged || layoutChanged) {
this.decorations = this.buildDecorations(update.view);
}
}
Expand Down

0 comments on commit d95f20b

Please sign in to comment.