From 3d9b0d29eae26f604a977bbd078f386aa2669f3f Mon Sep 17 00:00:00 2001 From: Michael Brenan Date: Fri, 6 Oct 2023 00:52:41 -0700 Subject: [PATCH] Fix up addition --- src/api/plugin-api.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/api/plugin-api.ts b/src/api/plugin-api.ts index 05b44308..3d4d1e83 100644 --- a/src/api/plugin-api.ts +++ b/src/api/plugin-api.ts @@ -13,6 +13,7 @@ import { Context } from "expression/context"; import { defaultLinkHandler, executeCalendar, + executeInline, executeList, executeTable, executeTask, @@ -21,7 +22,7 @@ import { import { DateTime, Duration } from "luxon"; import * as Luxon from "luxon"; import { compare, CompareOperator, satisfies } from "compare-versions"; -import { DataviewSettings, ExportSettings, QuerySettings } from "settings"; +import { DataviewSettings, ExportSettings } from "settings"; import { parseFrontmatter } from "data-import/markdown-file"; import { SListItem, SMarkdownPage } from "data-model/serialized/markdown"; import { createFixedTaskView, createTaskView, nestGroups } from "ui/views/task-view"; @@ -374,20 +375,12 @@ export class DataviewApi { return this.evaluate(expression, context, originFile).orElseThrow(); } - /** Execute a single field inline a file, returning the evaluated result. */ - executeInline(expression, origin, index, settings) { + /** Evaluate an expression in the context of the given file. */ + public evaluateInline(expression: string, origin: string): Result { let field = EXPRESSION.field.parse(expression); - if (!field.status) { - return Result.failure(`Failed to parse expression "${expression}"`); - } else { - index = index || this.index; - let result = executeInline(field.value, origin, index, settings); - if (!result.successful) { - return Result.failure(result.error); - } else { - return Result.success(result.value); - } - } + if (!field.status) return Result.failure(`Failed to parse expression "${expression}"`); + + return executeInline(field.value, origin, this.index, this.settings); } ///////////////