Переглянути джерело

Closes #954 - uses codicons in hovers

main
Eric Amodio 4 роки тому
джерело
коміт
acfca80dbd
2 змінених файлів з 41 додано та 36 видалено
  1. +14
    -14
      src/git/formatters/commitFormatter.ts
  2. +27
    -22
      src/hovers/hovers.ts

+ 14
- 14
src/git/formatters/commitFormatter.ts Переглянути файл

@ -235,33 +235,33 @@ export class CommitFormatter extends Formatter {
return commands;
}
const separator = '  ';
const separator = '   |   ';
commands = `[\`${this.id}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
commands = `---\n\n[$(git-commit) ${this.id}](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
this._item.sha
)} "Show Commit Details")${separator}`;
const { pullRequestOrRemote: pr } = this._options;
if (pr != null) {
if (PullRequest.is(pr)) {
commands += `[\`PR #${pr.number}\`](${pr.url} "Open Pull Request \\#${pr.number} on ${
commands += `[$(git-pull-request) PR #${pr.number}](${pr.url} "Open Pull Request \\#${pr.number} on ${
pr.provider
}\n${GlyphChars.Dash.repeat(2)}\n${pr.title}\n${pr.state}, ${pr.formatDateFromNow()}")${separator}`;
} else if (pr instanceof Promises.CancellationError) {
commands += `[\`PR ${GlyphChars.Ellipsis}\`](# "Searching for a Pull Request (if any) that introduced this commit...")${separator}`;
commands += `[$(git-pull-request) PR (${GlyphChars.Ellipsis})](# "Searching for a Pull Request (if any) that introduced this commit...")${separator}`;
} else if (pr.provider != null) {
commands += `[\`Connect to ${pr.provider.name}${
commands += `[$(plug) Connect to ${pr.provider.name}${
GlyphChars.Ellipsis
}\`](${ConnectRemoteProviderCommand.getMarkdownCommandArgs(pr)} "Connect to ${
}](${ConnectRemoteProviderCommand.getMarkdownCommandArgs(pr)} "Connect to ${
pr.provider.name
} to enable the display of the Pull Request (if any) that introduced this commit")${separator}`;
}
}
commands += `**[\`${GlyphChars.MuchLessThan}\`](${DiffWithCommand.getMarkdownCommandArgs(
commands += `[$(compare-changes)](${DiffWithCommand.getMarkdownCommandArgs(
this._item,
this._options.line
)} "Open Changes")**${separator}`;
)} "Open Changes")${separator}`;
if (this._item.previousSha !== undefined) {
let annotationType = this._options.annotationType;
@ -274,29 +274,29 @@ export class CommitFormatter extends Formatter {
this._item.previousUri.fsPath,
this._item.repoPath
);
commands += `**[\` ${GlyphChars.EqualsTriple} \`](${OpenFileRevisionCommand.getMarkdownCommandArgs(
commands += `[$(history)](${OpenFileRevisionCommand.getMarkdownCommandArgs(
uri,
annotationType || FileAnnotationType.Blame,
this._options.line
)} "Blame Previous Revision")**${separator}`;
)} "Blame Previous Revision")${separator}`;
}
if (this._options.remotes !== undefined && this._options.remotes.length !== 0) {
commands += `**[\` ${GlyphChars.ArrowUpRight} \`](${OpenCommitInRemoteCommand.getMarkdownCommandArgs(
commands += `[$(link-external)](${OpenCommitInRemoteCommand.getMarkdownCommandArgs(
this._item.sha
)} "Open on Remote")**${separator}`;
)} "Open on Remote")${separator}`;
}
if (this._item.author !== 'You') {
const presence = this._options.presence;
if (presence != null) {
commands += `[\` ${GlyphChars.Envelope}+ \`](${InviteToLiveShareCommand.getMarkdownCommandArgs(
commands += `[$(live-share)](${InviteToLiveShareCommand.getMarkdownCommandArgs(
this._item.email
)} "Invite ${this._item.author} (${presence.statusText}) to a Live Share Session")${separator}`;
}
}
commands += `[\`${GlyphChars.MiddleEllipsis}\`](${ShowQuickCommitFileDetailsCommand.getMarkdownCommandArgs({
commands += `[$(ellipsis)](${ShowQuickCommitFileDetailsCommand.getMarkdownCommandArgs({
revisionUri: GitUri.toRevisionUri(this._item.toGitUri()).toString(true)
})} "Show More Actions")`;

+ 27
- 22
src/hovers/hovers.ts Переглянути файл

@ -85,7 +85,7 @@ export namespace Hovers {
return undefined;
}
message = `[\`Changes\`](${DiffWithCommand.getMarkdownCommandArgs({
message = `[$(compare-changes) Changes](${DiffWithCommand.getMarkdownCommandArgs({
lhs: {
sha: diffUris.previous.sha || '',
uri: diffUris.previous.documentUri()
@ -105,9 +105,9 @@ export namespace Hovers {
working: 'Working Tree'
}
})}_`
: `[\`${GitService.shortenSha(
: `[$(git-commit) ${GitService.shortenSha(
diffUris.previous.sha || ''
)}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
)}](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
diffUris.previous.sha || ''
)} "Show Commit Details")`;
@ -118,26 +118,29 @@ export namespace Hovers {
working: 'Working Tree'
}
})}_`
: `[\`${GitService.shortenSha(
: `[$(git-commit) ${GitService.shortenSha(
diffUris.current.sha || ''
)}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
)}](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
diffUris.current.sha || ''
)} "Show Commit Details")`;
} else {
message = `[\`Changes\`](${DiffWithCommand.getMarkdownCommandArgs(commit, editorLine)} "Open Changes")`;
message = `[$(compare-changes) Changes](${DiffWithCommand.getMarkdownCommandArgs(
commit,
editorLine
)} "Open Changes")`;
previous = `[\`${commit.previousShortSha}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
commit.previousSha
)} "Show Commit Details")`;
previous = `[$(git-commit) ${
commit.previousShortSha
}](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(commit.previousSha)} "Show Commit Details")`;
current = `[\`${commit.shortSha}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
current = `[$(git-commit) ${commit.shortSha}](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
commit.sha
)} "Show Commit Details")`;
}
message += `   ${GlyphChars.Dash}   ${previous}  ${GlyphChars.ArrowLeftRightLong}  ${current}\n${diff}`;
const markdown = new MarkdownString(message);
const markdown = new MarkdownString(message, true);
markdown.isTrusted = true;
return markdown;
}
@ -155,16 +158,16 @@ export namespace Hovers {
const remotes = await Container.git.getRemotes(commit.repoPath, { sort: true });
const [previousLineDiffUris, autolinkedIssues, pr, presence] = await Promise.all([
const [previousLineDiffUris, autolinkedIssuesOrPullRequests, pr, presence] = await Promise.all([
commit.isUncommitted ? commit.getPreviousLineDiffUris(uri, editorLine, uri.sha) : undefined,
getAutoLinkedIssues(commit.message, remotes),
getAutoLinkedIssuesOrPullRequests(commit.message, remotes),
getPullRequestForCommit(commit.ref, remotes),
Container.vsls.maybeGetPresence(commit.email).catch(reason => undefined)
]);
const details = CommitFormatter.fromTemplate(Container.config.hovers.detailsMarkdownFormat, commit, {
annotationType: annotationType,
autolinkedIssues: autolinkedIssues,
autolinkedIssuesOrPullRequests: autolinkedIssuesOrPullRequests,
dateFormat: dateFormat,
line: editorLine,
markdown: true,
@ -174,7 +177,7 @@ export namespace Hovers {
remotes: remotes
});
const markdown = new MarkdownString(details);
const markdown = new MarkdownString(details, true);
markdown.isTrusted = true;
return markdown;
}
@ -189,7 +192,7 @@ export namespace Hovers {
}\n\`\`\``;
}
async function getAutoLinkedIssues(message: string, remotes: GitRemote[]) {
async function getAutoLinkedIssuesOrPullRequests(message: string, remotes: GitRemote[]) {
const cc = Logger.getNewCorrelationContext('Hovers.getAutoLinkedIssues');
Logger.debug(cc, `${GlyphChars.Dash} message=<message>`);
@ -216,11 +219,13 @@ export namespace Hovers {
const timeout = 250;
try {
const autolinkedIssues = await Container.autolinks.getIssueLinks(message, remote, { timeout: timeout });
const autolinks = await Container.autolinks.getIssueOrPullRequestLinks(message, remote, {
timeout: timeout
});
if (autolinkedIssues !== undefined && (Logger.level === TraceLevel.Debug || Logger.isDebugging)) {
if (autolinks !== undefined && (Logger.level === TraceLevel.Debug || Logger.isDebugging)) {
const timeouts = [
...Iterables.filterMap(autolinkedIssues.values(), issue =>
...Iterables.filterMap(autolinks.values(), issue =>
issue instanceof Promises.CancellationError ? issue.promise : undefined
)
];
@ -229,20 +234,20 @@ export namespace Hovers {
if (timeouts.length !== 0) {
Logger.debug(
cc,
`timed out ${GlyphChars.Dash} issue queries (${
`timed out ${GlyphChars.Dash} issue/pr queries (${
timeouts.length
}) took too long (over ${timeout} ms) ${GlyphChars.Dot} ${Strings.getDurationMilliseconds(
start
)} ms`
);
return autolinkedIssues;
return autolinks;
}
}
Logger.debug(cc, `completed ${GlyphChars.Dot} ${Strings.getDurationMilliseconds(start)} ms`);
return autolinkedIssues;
return autolinks;
} catch (ex) {
Logger.error(ex, cc, `failed ${GlyphChars.Dot} ${Strings.getDurationMilliseconds(start)} ms`);

Завантаження…
Відмінити
Зберегти