Skip to content

Commit

Permalink
fix: respect custom base path in open in github
Browse files Browse the repository at this point in the history
fix #284
  • Loading branch information
Vinzent03 committed Aug 24, 2022
1 parent bd8bafc commit c4e8acf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/openInGitHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { GitManager } from "./gitManager";
export async function openLineInGitHub(editor: Editor, file: TFile, manager: GitManager) {
const { isGitHub, branch, repo, user } = await getData(manager);
if (isGitHub) {
const path = manager.getPath(file.path, true);
const from = editor.getCursor("from").line + 1;
const to = editor.getCursor("to").line + 1;
if (from === to) {
window.open(`https://github.com/${user}/${repo}/blob/${branch}/${file.path}?plain=1#L${from}`);
window.open(`https://github.com/${user}/${repo}/blob/${branch}/${path}?plain=1#L${from}`);
} else {
window.open(`https://github.com/${user}/${repo}/blob/${branch}/${file.path}?plain=1#L${from}-L${to}`);
window.open(`https://github.com/${user}/${repo}/blob/${branch}/${path}?plain=1#L${from}-L${to}`);
}
} else {
new Notice('It seems like you are not using GitHub');
Expand All @@ -18,9 +19,10 @@ export async function openLineInGitHub(editor: Editor, file: TFile, manager: Git

export async function openHistoryInGitHub(file: TFile, manager: GitManager) {
const { isGitHub, branch, repo, user } = await getData(manager);
const path = manager.getPath(file.path, true);

if (isGitHub) {
window.open(`https://github.com/${user}/${repo}/commits/${branch}/${file.path}`);
window.open(`https://github.com/${user}/${repo}/commits/${branch}/${path}`);
} else {
new Notice('It seems like you are not using GitHub');
}
Expand Down

0 comments on commit c4e8acf

Please sign in to comment.