mirror of
https://github.com/dnlbauer/obsidian-dataview-autocompletion.git
synced 2026-09-11 14:45:30 +00:00
fix: inserted value should not use display value if display value is undefined
This commit is contained in:
@@ -122,14 +122,16 @@ export class DataviewSuggester extends EditorSuggest<String> {
|
|||||||
// If the value is a string, number or boolean, we can simply convert it to a string
|
// If the value is a string, number or boolean, we can simply convert it to a string
|
||||||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
||||||
stringValue = value.toString();
|
stringValue = value.toString();
|
||||||
} else if (dataviewAPI.value.typeOf(value) === "link" && value.type === "file" && value.display !== undefined) {
|
} else if (dataviewAPI.value.typeOf(value) === "link" && value.type === "file") {
|
||||||
// value.toString always adds a display value to wiki-style links.
|
// parse wiki-style links
|
||||||
// parse wiki-style links without display value manually here to prevent this from happening for [[filename]]
|
if (value.display !== undefined) {
|
||||||
stringValue = `[[${value.path.split("/").pop().replace(".md", "")}]]`;
|
stringValue = `[[${value.path.split("/").pop().replace(".md", "")}|${value.display}]]`;
|
||||||
|
} else {
|
||||||
|
stringValue = `[[${value.path.split("/").pop().replace(".md", "")}]]`;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
stringValue = dataviewAPI.value.toString(value);
|
stringValue = dataviewAPI.value.toString(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${key}:: ${stringValue}`;
|
return `${key}:: ${stringValue}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user