Finished addressing review.

This commit is contained in:
Caleb Campbell
2025-10-09 12:32:46 +11:00
parent 9911e0ce8a
commit 6c83e97297
4 changed files with 80 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
import { AbstractInputSuggest, App } from "obsidian";
import { AbstractInputSuggest, App, TFolder } from "obsidian";
export class PathSuggest extends AbstractInputSuggest<string> {
private textInputEl: HTMLInputElement | HTMLDivElement;
@@ -9,11 +9,12 @@ export class PathSuggest extends AbstractInputSuggest<string> {
}
async getSuggestions(query: string): Promise<string[]> {
let searchPath = '';
if (await this.app.vault.adapter.exists(query)) searchPath = query;
let folders = (await this.app.vault.adapter.list(searchPath)).folders;
folders = folders.filter(folder => !folder.startsWith('.') && folder.startsWith(query));
return folders;
query ||= '/';
const folder = this.app.vault.getFolderByPath(query);
if (!folder) return [];
return folder.children
.filter(c => c instanceof TFolder)
.map(f => f.path);
}
renderSuggestion(item: string, el: HTMLElement): void {