Browse Source

Fixes #3018 escapes () in markdown command links

main
Eric Amodio 1 year ago
parent
commit
1eb9f49904
4 changed files with 11 additions and 5 deletions
  1. +4
    -0
      CHANGELOG.md
  2. +2
    -1
      src/commands/base.ts
  3. +2
    -1
      src/git/formatters/commitFormatter.ts
  4. +3
    -3
      src/git/models/reference.ts

+ 4
- 0
CHANGELOG.md View File

@ -14,6 +14,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Refines AI prompts to provide better commit message generation and explanation results
### Fixed
- Fixes [#3018](https://github.com/gitkraken/vscode-gitlens/issues/3018) - Line blame overlay is broken when commit message contains a `)`
## [14.5.0] - 2023-11-13
### Added

+ 2
- 1
src/commands/base.ts View File

@ -285,7 +285,8 @@ export abstract class Command implements Disposable {
command: Commands | `${Commands.ActionPrefix}${ActionContext['type']}`,
args: T,
): string {
return `command:${command}?${encodeURIComponent(JSON.stringify(args))}`;
// Since we are using the command in a markdown link, we need to escape ()'s so they don't get interpreted as markdown
return `command:${command}?${encodeURIComponent(JSON.stringify(args)).replace(/([()])/g, '\$1')}`;
}
protected readonly contextParsingOptions: CommandContextParsingOptions = { expectsEditor: false };

+ 2
- 1
src/git/formatters/commitFormatter.ts View File

@ -438,7 +438,8 @@ export class CommitFormatter extends Formatter {
if (arePlusFeaturesEnabled()) {
commands += ` &nbsp;[$(gitlens-graph)](${Command.getMarkdownCommandArgsCore<ShowInCommitGraphCommandArgs>(
Commands.ShowInCommitGraph,
{ ref: getReferenceFromRevision(this._item) },
// Avoid including the message here, it just bloats the command url
{ ref: getReferenceFromRevision(this._item, { excludeMessage: true }) },
)} "Open in Commit Graph")`;
}

+ 3
- 3
src/git/models/reference.ts View File

@ -233,20 +233,20 @@ export function getReferenceFromBranch(branch: GitBranchReference) {
});
}
export function getReferenceFromRevision(revision: GitRevisionReference) {
export function getReferenceFromRevision(revision: GitRevisionReference, options?: { excludeMessage?: boolean }) {
if (revision.refType === 'stash') {
return createReference(revision.ref, revision.repoPath, {
refType: revision.refType,
name: revision.name,
number: revision.number,
message: revision.message,
message: options?.excludeMessage ? undefined : revision.message,
});
}
return createReference(revision.ref, revision.repoPath, {
refType: revision.refType,
name: revision.name,
message: revision.message,
message: options?.excludeMessage ? undefined : revision.message,
});
}

||||||
x
 
000:0
Loading…
Cancel
Save