summaryrefslogtreecommitdiff
path: root/source/features/repo-wide-file-finder.tsx
blob: 8ae92876ba0761ceff1bdaa287487fd9faca95c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';

import features from '../feature-manager.js';
import getDefaultBranch from '../github-helpers/get-default-branch.js';
import {buildRepoURL} from '../github-helpers/index.js';
import getCurrentGitRef from '../github-helpers/get-current-git-ref.js';
import {registerHotkey} from '../github-helpers/hotkey.js';

async function init(): Promise<void> {
	registerHotkey('t', buildRepoURL('tree', getCurrentGitRef() ?? await getDefaultBranch()) + '?search=1');
}

void features.add(import.meta.url, {
	include: [
		pageDetect.isRepo,
	],
	exclude: [
		() => select.exists('[data-hotkey="t"]'),
		pageDetect.isEmptyRepo,
		pageDetect.isPRFiles,
		pageDetect.isFileFinder,
	],
	init,
});