mirror of
https://github.com/dnlbauer/obsidian-dataview-autocompletion.git
synced 2026-09-10 14:15:29 +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 (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
||||
stringValue = value.toString();
|
||||
} else if (dataviewAPI.value.typeOf(value) === "link" && value.type === "file" && value.display !== undefined) {
|
||||
// value.toString always adds a display value to wiki-style links.
|
||||
// parse wiki-style links without display value manually here to prevent this from happening for [[filename]]
|
||||
stringValue = `[[${value.path.split("/").pop().replace(".md", "")}]]`;
|
||||
} else if (dataviewAPI.value.typeOf(value) === "link" && value.type === "file") {
|
||||
// parse wiki-style links
|
||||
if (value.display !== undefined) {
|
||||
stringValue = `[[${value.path.split("/").pop().replace(".md", "")}|${value.display}]]`;
|
||||
} else {
|
||||
stringValue = `[[${value.path.split("/").pop().replace(".md", "")}]]`;
|
||||
}
|
||||
} else {
|
||||
stringValue = dataviewAPI.value.toString(value);
|
||||
}
|
||||
|
||||
return `${key}:: ${stringValue}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user