From e0fb281eba4ba96897762154183580dd09341c40 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Tue, 21 Dec 2021 00:40:46 -0500 Subject: [PATCH] (core) When searching, use formatter.formatAny() to handle values of invalid type. Summary: This turns out necessary because ReferenceList columns are formatted using the formatter of the associated visibleCol. This works correctly in dedicated widgets, but in generic code (like SearchModel here), this formatter needs to handle unexpected values (of type ReferenceList). Without the fix, it produces JS errors when search reaches a RefList: column. A better fix would allow a formatter to know that it expects a ReferenceList, AND to know how to format each value of it, but that's a bigger question that's outside the scope of this fix. Test Plan: Includes a browser test which reproduces the bug. Reviewers: cyprien Reviewed By: cyprien Differential Revision: https://phab.getgrist.com/D3195 --- app/client/models/SearchModel.ts | 2 +- app/server/lib/ActiveDoc.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/client/models/SearchModel.ts b/app/client/models/SearchModel.ts index 5c760839..be23d70b 100644 --- a/app/client/models/SearchModel.ts +++ b/app/client/models/SearchModel.ts @@ -266,7 +266,7 @@ class FinderImpl implements IFinder { const value = this._sectionTableData.getValue(rowId, displayCol.colId.peek()); // TODO: Note that formatting dates is now the bulk of the performance cost. - const text = formatter.format(value); + const text = formatter.formatAny(value); return this._searchRegexp.test(text); } diff --git a/app/server/lib/ActiveDoc.ts b/app/server/lib/ActiveDoc.ts index 605194b8..447f1d06 100644 --- a/app/server/lib/ActiveDoc.ts +++ b/app/server/lib/ActiveDoc.ts @@ -1371,12 +1371,12 @@ export class ActiveDoc extends EventEmitter { options: ApplyUAOptions = {}): Promise { const client = docSession.client; - this._log.debug(docSession, "_applyUserActions(%s, %s)", client, shortDesc(actions)); + this._log.debug(docSession, "_applyUserActions(%s, %s)%s", client, shortDesc(actions), + options.parseStrings ? ' (will parse)' : ''); this._inactivityTimer.ping(); // The doc is in active use; ping it to stay open longer. if (options.parseStrings) { actions = actions.map(ua => parseUserAction(ua, this.docData!)); - this._log.debug(docSession, "_applyUserActions(%s, %s) (after parsing)", client, shortDesc(actions)); } if (options?.bestEffort) {