mirror of
https://github.com/idreesinc/Waypoint.git
synced 2026-07-22 06:20:32 +00:00
Merge pull request #131 from Evilur/master
feat: #25 add option 'Folders sorted to the top'
This commit is contained in:
commit
3663bbfab0
1 changed files with 23 additions and 0 deletions
23
main.ts
23
main.ts
|
|
@ -30,6 +30,7 @@ interface WaypointSettings {
|
|||
stopScanAtFolderNotes: boolean;
|
||||
showFolderNotes: boolean;
|
||||
showNonMarkdownFiles: boolean;
|
||||
foldersOnTop: boolean;
|
||||
debugLogging: boolean;
|
||||
useWikiLinks: boolean;
|
||||
useFrontMatterTitle: boolean;
|
||||
|
|
@ -46,6 +47,7 @@ const DEFAULT_SETTINGS: WaypointSettings = {
|
|||
stopScanAtFolderNotes: false,
|
||||
showFolderNotes: false,
|
||||
showNonMarkdownFiles: false,
|
||||
foldersOnTop: true,
|
||||
debugLogging: false,
|
||||
useWikiLinks: true,
|
||||
useFrontMatterTitle: false,
|
||||
|
|
@ -390,6 +392,18 @@ export default class Waypoint extends Plugin {
|
|||
}
|
||||
if (children.length > 0) {
|
||||
const nextIndentLevel = topLevel && !this.settings.showEnclosingNote ? indentLevel : indentLevel + 1;
|
||||
|
||||
/* If enabled 'folders sorted to the top',
|
||||
* sort according to the node type
|
||||
*/
|
||||
if (this.settings.foldersOnTop) {
|
||||
children.sort((x, y) => {
|
||||
if (x instanceof TFolder
|
||||
&& !(y instanceof TFolder)) return -1;
|
||||
else return 1;
|
||||
});
|
||||
}
|
||||
|
||||
text += (text === "" ? "" : "\n") + (await Promise.all(children.map((child) => this.getFileTreeRepresentation(rootNode, child, nextIndentLevel)))).filter(Boolean).join("\n");
|
||||
}
|
||||
return text;
|
||||
|
|
@ -597,6 +611,15 @@ class WaypointSettingsTab extends PluginSettingTab {
|
|||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName("Folders sorted to the top")
|
||||
.setDesc("If enabled, folders will be listed at the top in the generated waypoints.")
|
||||
.addToggle((toggle) =>
|
||||
toggle.setValue(this.plugin.settings.foldersOnTop).onChange(async (value) => {
|
||||
this.plugin.settings.foldersOnTop = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName("Stop Scan at Folder Notes")
|
||||
.setDesc("If enabled, the waypoint generator will stop scanning nested folders when it encounters a folder note. Otherwise, it will only stop if the folder note contains a waypoint.")
|
||||
|
|
|
|||
Loading…
Reference in a new issue