Skip to content

Commit

Permalink
fix: open diff view in correct pane
Browse files Browse the repository at this point in the history
close #252
  • Loading branch information
Vinzent03 committed Jul 16, 2022
1 parent 0d5ec26 commit 96d2913
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ui/sidebar/components/fileComponent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
}
function showDiff(event: MouseEvent) {
const leaf = workspace.activeLeaf;
const leaf = workspace.getMostRecentLeaf(workspace.rootSplit);
if (
leaf &&
Expand Down
18 changes: 11 additions & 7 deletions src/ui/sidebar/components/stagedFileComponent.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { setIcon } from "obsidian";
import { FileView, setIcon, TAbstractFile } from "obsidian";
import { hoverPreview, openOrSwitch } from "obsidian-community-lib";
import { format } from "path";
import { format } from "path";
import { DIFF_VIEW_CONFIG } from "src/constants";
import { GitManager } from "src/gitManager";
import { FileStatusResult } from "src/types";
Expand Down Expand Up @@ -45,8 +45,9 @@ import { format } from "path";
}
function showDiff(event: MouseEvent) {
const leaf = view.app.workspace.activeLeaf;
const workspace = view.app.workspace;
const leaf = workspace.getMostRecentLeaf(workspace.rootSplit);
if (
leaf &&
!leaf.getViewState().pinned &&
Expand All @@ -59,9 +60,10 @@ import { format } from "path";
staged: true,
},
});
workspace.setActiveLeaf(leaf,true,true)
} else {
view.app.workspace
.createLeafInParent(view.app.workspace.rootSplit, 0)
workspace
.createLeafInParent(workspace.rootSplit, 0)
.setViewState({
type: DIFF_VIEW_CONFIG.type,
active: true,
Expand All @@ -84,7 +86,9 @@ import { format } from "path";
<span
class="path"
aria-label-position={side}
aria-label={formattedPath.split("/").last() != formattedPath ? formattedPath : ""}
aria-label={formattedPath.split("/").last() != formattedPath
? formattedPath
: ""}
on:click={showDiff}
>
{formattedPath.split("/").last().replace(".md", "")}
Expand Down

0 comments on commit 96d2913

Please sign in to comment.