(fieldInput: string)
| 732 | } |
| 733 | |
| 734 | protected async suggestForField(fieldInput: string): Promise<string | string[]> { |
| 735 | this.assertInteractivePrompt(`{{FIELD:${fieldInput}}}`); |
| 736 | // Route the final picker to a remote interactive session (Raycast) when one |
| 737 | // is driving; the vault-side value collection below still runs unchanged. |
| 738 | const provider = this.choiceExecutor?.promptProvider; |
| 739 | try { |
| 740 | // Parse the field input to extract field name and filters. Do NOT warn |
| 741 | // on unknown keys here: the field replacer in formatter.ts already parses |
| 742 | // the same token with { warnUnknown: true } before calling this, so |
| 743 | // warning again would emit a duplicate notice per malformed FIELD token. |
| 744 | const { fieldName, filters, multiSelect } = |
| 745 | FieldSuggestionParser.parse(fieldInput); |
| 746 | |
| 747 | // Resolve the active-note default (issue #1429) BEFORE collection but apply |
| 748 | // it AFTER, so the resolved value never enters the collection cache key |
| 749 | // (which is keyed partly on filters.defaultValue). Gate strictly on |
| 750 | // "active"; an unknown source is ignored. `null` => no usable active value |
| 751 | // (no/non-Markdown active file, or a missing/empty/object property). |
| 752 | const activeDefault = |
| 753 | filters.defaultFrom === "active" |
| 754 | ? resolveActiveNoteFieldDefault( |
| 755 | this.app, |
| 756 | this.choiceExecutor?.triggerContext?.activeFile ?? null, |
| 757 | fieldName, |
| 758 | ) |
| 759 | : null; |
| 760 | |
| 761 | // Collect and process via shared collector (filters unmutated). |
| 762 | const { values: collectedValues, hasDefaultValue: literalHasDefault } = |
| 763 | await collectFieldValuesProcessedDetailed(this.app, fieldName, filters); |
| 764 | |
| 765 | let values = collectedValues; |
| 766 | let hasDefaultValue = literalHasDefault; |
| 767 | // The default shown in the placeholder hint: the active-note value wins |
| 768 | // over a literal |default: when both are present. |
| 769 | let effectiveDefault = filters.defaultValue; |
| 770 | |
| 771 | if (!multiSelect && typeof activeDefault === "string") { |
| 772 | // Promote the active note's scalar value to the top so an empty-query |
| 773 | // Enter accepts it, matching the existing default-always semantics. |
| 774 | values = FieldValueProcessor.promoteValueToFront( |
| 775 | values, |
| 776 | activeDefault, |
| 777 | filters.caseSensitive, |
| 778 | ); |
| 779 | effectiveDefault = activeDefault; |
| 780 | hasDefaultValue = true; |
| 781 | } else if ( |
| 782 | !multiSelect && |
| 783 | Array.isArray(activeDefault) && |
| 784 | activeDefault.length > 0 |
| 785 | ) { |
| 786 | // A list-valued property has no single default; lists apply to |multi |
| 787 | // only. Log (console-only) so a user expecting a default isn't mystified. |
| 788 | log.logMessage( |
| 789 | `{{FIELD:${fieldName}|default-from:active}}: the active note's "${fieldName}" is a list value, which applies only to |multi FIELD prompts, so no default was prefilled.`, |
| 790 | ); |
| 791 | } |
nothing calls this directly
no test coverage detected