Skip to content

Commit

Permalink
fix(CreateIndex): 🐛 Adjust for mainG
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 21, 2021
1 parent 9110e2d commit 833c6a1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 52 deletions.
46 changes: 25 additions & 21 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23684,9 +23684,11 @@ class MatrixView extends obsidian.ItemView {
callback: async () => {
const { settings, mainG } = this.plugin;
const { basename } = this.app.workspace.getActiveFile();
const closedDown = getReflexiveClosure(getSubInDirs(mainG, "down"), settings.userHiers);
const allPaths = this.dfsAllPaths(closedDown, basename);
const index = this.createIndex(basename + "\n", allPaths, settings);
const g = getSubInDirs(mainG, "up", "down");
const closed = getReflexiveClosure(g, settings.userHiers);
const onlyDowns = getSubInDirs(closed, "down");
const allPaths = this.dfsAllPaths(onlyDowns, basename);
const index = this.createIndex(allPaths, settings);
debug(settings, { index });
await copy$1(index);
},
Expand All @@ -23696,14 +23698,15 @@ class MatrixView extends obsidian.ItemView {
name: "Copy a Global Index to the clipboard",
callback: async () => {
const { mainG, settings } = this.plugin;
const upSub = getSubInDirs(mainG, "up");
const closedDown = getReflexiveClosure(getSubInDirs(mainG, "down"), settings.userHiers);
const sinks = getSinks(upSub);
const g = getSubInDirs(mainG, "up", "down");
const closed = getReflexiveClosure(g, settings.userHiers);
const onlyDowns = getSubInDirs(closed, "down");
const sinks = getSinks(mainG);
let globalIndex = "";
sinks.forEach((terminal) => {
globalIndex += terminal + "\n";
const allPaths = this.dfsAllPaths(closedDown, terminal);
globalIndex = this.createIndex(globalIndex, allPaths, settings);
const allPaths = this.dfsAllPaths(onlyDowns, terminal);
globalIndex += this.createIndex(allPaths, settings);
});
debug(settings, { globalIndex });
await copy$1(globalIndex);
Expand Down Expand Up @@ -23765,7 +23768,8 @@ class MatrixView extends obsidian.ItemView {
}
return allPaths;
}
createIndex(index, allPaths, settings) {
createIndex(allPaths, settings) {
let index = "";
const { wikilinkIndex } = settings;
const copy = lodash.cloneDeep(allPaths);
const reversed = copy.map((path) => path.reverse());
Expand Down Expand Up @@ -36577,18 +36581,18 @@ class BCPlugin extends obsidian.Plugin {
name: "Refresh Breadcrumbs Index",
callback: async () => await this.refreshIndex(),
});
this.addCommand({
id: "test-traversal",
name: "Traverse",
hotkeys: [{ key: "a", modifiers: ["Alt"] }],
callback: () => {
const { basename } = this.app.workspace.getActiveFile();
const g = getSubInDirs(this.mainG, "up", "down");
const closed = getReflexiveClosure(g, this.settings.userHiers);
const onlyUps = getSubInDirs(closed, "up");
this.getdfsFromNode(onlyUps, basename);
},
});
// this.addCommand({
// id: "test-traversal",
// name: "Traverse",
// hotkeys: [{ key: "a", modifiers: ["Alt"] }],
// callback: () => {
// const { basename } = this.app.workspace.getActiveFile();
// const g = getSubInDirs(this.mainG, "up", "down");
// const closed = getReflexiveClosure(g, this.settings.userHiers);
// const onlyUps = getSubInDirs(closed, "up");
// this.getdfsFromNode(onlyUps, basename);
// },
// });
this.addCommand({
id: "Write-Breadcrumbs-to-Current-File",
name: "Write Breadcrumbs to Current File",
Expand Down
33 changes: 14 additions & 19 deletions src/MatrixView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ export default class MatrixView extends ItemView {
const { settings, mainG } = this.plugin;
const { basename } = this.app.workspace.getActiveFile();

const closedDown = getReflexiveClosure(
getSubInDirs(mainG, "down"),
settings.userHiers
);
const g = getSubInDirs(mainG, "up", "down");
const closed = getReflexiveClosure(g, settings.userHiers);
const onlyDowns = getSubInDirs(closed, "down");

const allPaths = this.dfsAllPaths(closedDown, basename);
const index = this.createIndex(basename + "\n", allPaths, settings);
const allPaths = this.dfsAllPaths(onlyDowns, basename);
const index = this.createIndex(allPaths, settings);
debug(settings, { index });
await copy(index);
},
Expand All @@ -76,19 +75,18 @@ export default class MatrixView extends ItemView {
name: "Copy a Global Index to the clipboard",
callback: async () => {
const { mainG, settings } = this.plugin;
const upSub = getSubInDirs(mainG, "up");
const closedDown = getReflexiveClosure(
getSubInDirs(mainG, "down"),
settings.userHiers
);

const sinks = getSinks(upSub);
const g = getSubInDirs(mainG, "up", "down");
const closed = getReflexiveClosure(g, settings.userHiers);
const onlyDowns = getSubInDirs(closed, "down");

const sinks = getSinks(mainG);

let globalIndex = "";
sinks.forEach((terminal) => {
globalIndex += terminal + "\n";
const allPaths = this.dfsAllPaths(closedDown, terminal);
globalIndex = this.createIndex(globalIndex, allPaths, settings);
const allPaths = this.dfsAllPaths(onlyDowns, terminal);
globalIndex += this.createIndex(allPaths, settings);
});

debug(settings, { globalIndex });
Expand Down Expand Up @@ -175,11 +173,8 @@ export default class MatrixView extends ItemView {
return allPaths;
}

createIndex(
index: string,
allPaths: string[][],
settings: BCSettings
): string {
createIndex(allPaths: string[][], settings: BCSettings): string {
let index = "";
const { wikilinkIndex } = settings;
const copy = cloneDeep(allPaths);
const reversed = copy.map((path) => path.reverse());
Expand Down
26 changes: 14 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,19 @@ export default class BCPlugin extends Plugin {
name: "Refresh Breadcrumbs Index",
callback: async () => await this.refreshIndex(),
});
this.addCommand({
id: "test-traversal",
name: "Traverse",
hotkeys: [{ key: "a", modifiers: ["Alt"] }],
callback: () => {
const { basename } = this.app.workspace.getActiveFile();
const g = getSubInDirs(this.mainG, "up", "down");
const closed = getReflexiveClosure(g, this.settings.userHiers);
const onlyUps = getSubInDirs(closed, "up");
this.getdfsFromNode(onlyUps, basename);
},
});
// this.addCommand({
// id: "test-traversal",
// name: "Traverse",
// hotkeys: [{ key: "a", modifiers: ["Alt"] }],
// callback: () => {
// const { basename } = this.app.workspace.getActiveFile();
// const g = getSubInDirs(this.mainG, "up", "down");
// const closed = getReflexiveClosure(g, this.settings.userHiers);
// const onlyUps = getSubInDirs(closed, "up");

// this.getdfsFromNode(onlyUps, basename);
// },
// });

this.addCommand({
id: "Write-Breadcrumbs-to-Current-File",
Expand Down Expand Up @@ -607,6 +608,7 @@ export default class BCPlugin extends Plugin {
);
subGraph = getSubForFields(this.mainG, [...positiveFields, ...oppFields]);
}

const closed = getReflexiveClosure(subGraph, userHiers);
return getSubForFields(closed, upFields);
}
Expand Down

0 comments on commit 833c6a1

Please sign in to comment.