Make issue suggestion work for all editors (#33340)

And do not handle special keys when the text-expander popup exists
This commit is contained in:
wxiaoguang 2025-01-21 19:33:45 +08:00 committed by GitHub
parent 46d1e91aed
commit 2cb3946496
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 34 additions and 16 deletions

View file

@ -1,5 +1,5 @@
import {decode, encode} from 'uint8-to-base64';
import type {IssuePageInfo, IssuePathInfo} from './types.ts';
import type {IssuePageInfo, IssuePathInfo, RepoOwnerPathInfo} from './types.ts';
// transform /path/to/file.ext to file.ext
export function basename(path: string): string {
@ -32,16 +32,17 @@ export function stripTags(text: string): string {
}
export function parseIssueHref(href: string): IssuePathInfo {
// FIXME: it should use pathname and trim the appSubUrl ahead
const path = (href || '').replace(/[#?].*$/, '');
const [_, ownerName, repoName, pathType, indexString] = /([^/]+)\/([^/]+)\/(issues|pulls)\/([0-9]+)/.exec(path) || [];
return {ownerName, repoName, pathType, indexString};
}
export function parseIssueNewHref(href: string): IssuePathInfo {
const path = (href || '').replace(/[#?].*$/, '');
const [_, ownerName, repoName, pathTypeField] = /([^/]+)\/([^/]+)\/(issues\/new|compare\/.+\.\.\.)/.exec(path) || [];
const pathType = pathTypeField ? (pathTypeField.startsWith('issues/new') ? 'issues' : 'pulls') : undefined;
return {ownerName, repoName, pathType};
export function parseRepoOwnerPathInfo(pathname: string): RepoOwnerPathInfo {
const appSubUrl = window.config.appSubUrl;
if (appSubUrl && pathname.startsWith(appSubUrl)) pathname = pathname.substring(appSubUrl.length);
const [_, ownerName, repoName] = /([^/]+)\/([^/]+)/.exec(pathname) || [];
return {ownerName, repoName};
}
export function parseIssuePageInfo(): IssuePageInfo {