Skip to content

Commit

Permalink
fix: full directory path on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Oct 18, 2022
1 parent a09bc4a commit 0f2c9d5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
22 changes: 15 additions & 7 deletions src/gitManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,20 @@ export abstract class GitManager {
return item.path.substring(beginLength).startsWith(title + "/");
});
childrenWithSameTitle.forEach((item) => children.remove(item));
const path = first.path.substring(0, restPath.indexOf("/") + beginLength);
list.push({
title: title,
path: first.path.substring(0, restPath.indexOf("/") + beginLength),
path: path,
vaultPath: this.getVaultPath(path),
children: this._getTreeStructure(childrenWithSameTitle, (beginLength > 0 ? (beginLength + title.length) : title.length) + 1)
});
} else {
list.push({ title: restPath, statusResult: first, path: first.path });
list.push({
title: restPath,
statusResult: first,
path: first.path,
vaultPath: this.getVaultPath(first.path)
});
children.remove(first);
}
}
Expand All @@ -124,11 +131,12 @@ export abstract class GitManager {
const singleChildIsDir = node.children?.first()?.statusResult == undefined;

if (!(node.children != undefined && singleChild && singleChildIsDir)) break;

node.title += "/" + node.children.first()!.title;
node.statusResult = node.children.first()!.statusResult;
node.path = node.children.first()!.path;
node.children = node.children.first()!.children;
const child = node.children.first()!;
node.title += "/" + child.title;
node.statusResult = child.statusResult;
node.path = child.path;
node.vaultPath = child.vaultPath;
node.children = child.children;
}
if (node.children != undefined) {
this.simplify(node.children);
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export interface BranchInfo {
export interface TreeItem {
title: string;
path: string;
vaultPath: string;
statusResult?: FileStatusResult;
children?: TreeItem[];
}
Expand Down
13 changes: 8 additions & 5 deletions src/ui/sidebar/components/treeComponent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
export let fileType: FileType;
export let topLevel = false;
const closed: Record<string, boolean> = {};
$: side = (view.leaf.getRoot() as any).side == "left" ? "right" : "left";
function stage(path: string) {
plugin.gitManager.stageAll({ dir: path }).finally(() => {
dispatchEvent(new CustomEvent("git-refresh"));
Expand All @@ -25,11 +27,7 @@
});
}
function discard(item: TreeItem) {
new DiscardModal(
view.app,
false,
plugin.gitManager.getVaultPath(item.path)
)
new DiscardModal(view.app, false, item.vaultPath)
.myOpen()
.then((shouldDiscard) => {
if (shouldDiscard === true) {
Expand Down Expand Up @@ -73,6 +71,11 @@
<div class="nav-folder" class:is-collapsed={closed[entity.title]}>
<div
class="nav-folder-title"
aria-label-position={side}
aria-label={entity.vaultPath.split("/").last() !=
entity.vaultPath
? entity.vaultPath
: ""}
on:click|self={() => fold(entity)}
>
<div
Expand Down
3 changes: 3 additions & 0 deletions src/ui/sidebar/gitView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
lastPulledFilesHierarchy = {
title: "",
path: "",
vaultPath: "",
children: plugin.gitManager.getTreeStructure(lastPulledFiles),
};
}
Expand All @@ -109,13 +110,15 @@
changeHierarchy = {
title: "",
path: "",
vaultPath: "",
children: plugin.gitManager.getTreeStructure(
status.changed
),
};
stagedHierarchy = {
title: "",
path: "",
vaultPath: "",
children: plugin.gitManager.getTreeStructure(status.staged),
};
}
Expand Down

0 comments on commit 0f2c9d5

Please sign in to comment.