diff options
Diffstat (limited to 'source/features/edit-files-faster.tsx')
-rw-r--r-- | source/features/edit-files-faster.tsx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/source/features/edit-files-faster.tsx b/source/features/edit-files-faster.tsx index e8487dcd..4c24792d 100644 --- a/source/features/edit-files-faster.tsx +++ b/source/features/edit-files-faster.tsx @@ -4,8 +4,10 @@ import select from 'select-dom'; import features from '../libs/features'; import * as icons from '../libs/icons'; import {wrap} from '../libs/dom-utils'; +import getDefaultBranch from '../libs/get-default-branch'; -function init(): void { +async function init(): Promise<void> { + const defaultBranch = await getDefaultBranch(); for (const fileIcon of select.all('.files :not(a) > .octicon-file')) { const pathnameParts = fileIcon .closest('tr')! @@ -15,6 +17,11 @@ function init(): void { pathnameParts[3] = 'edit'; // Replaces `/blob/` + const isPermalink = /Tag|Tree/.test(select('.branch-select-menu i')!.textContent!); + if (isPermalink) { + pathnameParts[4] = defaultBranch; // Replaces /${tag|commit}/ + } + wrap(fileIcon, <a href={pathnameParts.join('/')} className="rgh-edit-files-faster" />); fileIcon.after(icons.edit()); } |