diff --git a/src/BreadcrumbsSettingTab.ts b/src/BreadcrumbsSettingTab.ts index b949de4d..a472a461 100644 --- a/src/BreadcrumbsSettingTab.ts +++ b/src/BreadcrumbsSettingTab.ts @@ -342,6 +342,21 @@ export class BCSettingTab extends PluginSettingTab { }) ); + new Setting(MLViewDetails) + .setName("Sort by note name, but show alias") + .setDesc( + "When this is turned off, notes will first be sorted by their alias, and then by their name if no alias is found. Turn this on to sort by note name always, but still show the alias in the results." + ) + .addToggle((toggle) => + toggle + .setValue(settings.sortByNameShowAlias) + .onChange(async (value) => { + settings.sortByNameShowAlias = value; + await plugin.saveSettings(); + await plugin.getActiveTYPEView(MATRIX_VIEW).draw(); + }) + ); + new Setting(MLViewDetails) .setName("Make Current Note an Implied Sibling") .setDesc( diff --git a/src/MatrixView.ts b/src/MatrixView.ts index 0f1e8480..ca7673fe 100644 --- a/src/MatrixView.ts +++ b/src/MatrixView.ts @@ -115,6 +115,7 @@ export default class MatrixView extends ItemView { enableAlphaSort, treatCurrNodeAsImpliedSibling, squareDirectionsOrder, + sortByNameShowAlias, } = settings; if (!mainG) return []; @@ -208,7 +209,8 @@ export default class MatrixView extends ItemView { if (enableAlphaSort) { squares.forEach((sq) => sq.sort((a, b) => - (a.alt ?? a.to) < (b.alt ?? b.to) + (sortByNameShowAlias ? a.to : a.alt ?? a.to) < + (sortByNameShowAlias ? b.to : b.alt ?? b.to) ? alphaSortAsc ? -1 : 1 diff --git a/src/constants.ts b/src/constants.ts index 721d56cb..88d1da4d 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -230,6 +230,7 @@ export const DEFAULT_SETTINGS: BCSettings = { showTrail: true, showGrid: true, showPrevNext: true, + sortByNameShowAlias: false, squareDirectionsOrder: [0, 1, 2, 3, 4], limitTrailCheckboxes: [], limitJumpToFirstFields: [], diff --git a/src/interfaces.ts b/src/interfaces.ts index 4bbddfdc..af46967f 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -58,6 +58,7 @@ export interface BCSettings { showNameOrType: boolean; showRelationType: boolean; showWriteAllBCsCmd: boolean; + sortByNameShowAlias: boolean; regexNoteField: string; rlLeaf: boolean; showBCs: boolean;