File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import {
1212 getCurrentFileNamePreview ,
1313 DateFormatPreviewGenerator
1414} from "./helpers/previewHelpers" ;
15- import { VALUE_LABEL_KEY_DELIMITER } from "../utils/valueSyntax" ;
15+ import { getValueVariableBaseName } from "../utils/valueSyntax" ;
1616
1717import type QuickAdd from "../main" ;
1818
@@ -74,8 +74,7 @@ export class FileNameDisplayFormatter extends Formatter {
7474 protected getVariableValue ( variableName : string ) : string {
7575 const stored = this . variables . get ( variableName ) ;
7676 if ( typeof stored === "string" ) return stored ;
77- const baseName =
78- variableName . split ( VALUE_LABEL_KEY_DELIMITER ) [ 0 ] ?? variableName ;
77+ const baseName = getValueVariableBaseName ( variableName ) ;
7978 return getVariableExample ( baseName ) ;
8079 }
8180
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import {
1414 getCurrentFileNamePreview ,
1515 DateFormatPreviewGenerator
1616} from "./helpers/previewHelpers" ;
17- import { VALUE_LABEL_KEY_DELIMITER } from "../utils/valueSyntax" ;
17+ import { getValueVariableBaseName } from "../utils/valueSyntax" ;
1818
1919export class FormatDisplayFormatter extends Formatter {
2020 constructor (
@@ -77,8 +77,7 @@ export class FormatDisplayFormatter extends Formatter {
7777 protected getVariableValue ( variableName : string ) : string {
7878 const stored = this . variables . get ( variableName ) ;
7979 if ( typeof stored === "string" ) return stored ;
80- const baseName =
81- variableName . split ( VALUE_LABEL_KEY_DELIMITER ) [ 0 ] ?? variableName ;
80+ const baseName = getValueVariableBaseName ( variableName ) ;
8281 return getVariableExample ( baseName ) ;
8382 }
8483
Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ export function buildValueVariableKey(
2424 : variableName ;
2525}
2626
27+ export function getValueVariableBaseName ( variableKey : string ) : string {
28+ const delimiterIndex = variableKey . indexOf ( VALUE_LABEL_KEY_DELIMITER ) ;
29+ if ( delimiterIndex === - 1 ) return variableKey ;
30+ return variableKey . slice ( 0 , delimiterIndex ) ;
31+ }
32+
2733type ParsedOptions = {
2834 label ?: string ;
2935 defaultValue : string ;
You can’t perform that action at this time.
0 commit comments