From 0b39ab1a265070e6498939d0a08191946af6af81 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 5 Jun 2026 11:30:06 -0300 Subject: find, data: redirection overrides, use nameForReferencingAcrossWiki --- src/find.js | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'src/find.js') diff --git a/src/find.js b/src/find.js index ddd6ae05..6436532a 100644 --- a/src/find.js +++ b/src/find.js @@ -58,13 +58,25 @@ export function fuzzName(name, fuzz = {}) { return name; } +export function nativeGetMatchableNames(thing, _nativeGetMatchableNames) { + if (thing.nameForReferencingAcrossWiki === null) { + return []; + } + + if (thing.nameForReferencingAcrossWiki) { + return [thing.nameForReferencingAcrossWiki]; + } + + if (thing.name) { + return [thing.name]; + } + + return []; +} + export function processAvailableMatchesByName(data, fuzz, { include = _thing => true, - - getMatchableNames = thing => - (thing.constructor.hasPropertyDescriptor('name') - ? [thing.name] - : []), + getMatchableNames = nativeGetMatchableNames, results = Object.create(null), multipleNameMatches = Object.create(null), @@ -72,7 +84,7 @@ export function processAvailableMatchesByName(data, fuzz, { for (const thing of data) { if (!include(thing)) continue; - for (const name of getMatchableNames(thing)) { + for (const name of getMatchableNames(thing, nativeGetMatchableNames)) { if (typeof name !== 'string') { logWarn`Unexpected ${typeAppearance(name)} returned in names for ${inspect(thing)}`; continue; @@ -99,20 +111,24 @@ export function processAvailableMatchesByName(data, fuzz, { return {results, multipleNameMatches}; } +export function nativeGetMatchableDirectories(thing, _nativeGetMatchableDirectories) { + if (thing.directory) { + return [thing.directory]; + } else { + return []; + } +} + export function processAvailableMatchesByDirectory(data, { include = _thing => true, - - getMatchableDirectories = thing => - (thing.constructor.hasPropertyDescriptor('directory') - ? [thing.directory] - : [null]), + getMatchableDirectories = nativeGetMatchableDirectories, results = Object.create(null), }) { for (const thing of data) { if (!include(thing, thingConstructors)) continue; - for (const directory of getMatchableDirectories(thing)) { + for (const directory of getMatchableDirectories(thing, nativeGetMatchableDirectories)) { if (typeof directory !== 'string') { logWarn`Unexpected ${typeAppearance(directory)} returned in directories for ${inspect(thing)}`; continue; -- cgit 1.3.0-6-gf8a5