@ -0,0 +1,5 @@ | |||
<!--<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"> <g fill-rule="evenodd" clip-path="url(#clip0)" clip-rule="evenodd"> <path fill="#C5C5C5" d="M1 2.5l.5-.5h5.7l.3.1 3.4 3.5.1.4v2.44l-.854-.854-.146.146V7H6V3H2v11h6.732l1 1H1.5l-.5-.5v-12zM11 11v1h-1v-1h1zm-1-.44l.854-.853L10.146 9 10 9.146v1.415zm0 3.294l.146.146.708-.707-.854-.854v1.415zM7 3l2.903 3H7V3z"/> <path fill="#75BEFF" d="M10.146 14L8 11.854v-.707L10.146 9l.708.707L9.56 11h3a2.5 2.5 0 0 1 0 5h-.5v-1h.5a1.5 1.5 0 1 0 0-3h-3l1.293 1.293-.708.707z"/> </g> <defs> <clipPath id="clip0"> <path fill="#fff" d="M0 0h16v16H0z"/> </clipPath> </defs> </svg>--> | |||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"> | |||
<path fill="#C5C5C5" fill-rule="evenodd" d="M11 6.56l-.854.854L10 7.268V14H2V3h4v4h3.732l-1-1H7V2.732l.565-.565L7.5 2.1 7.2 2H1.5l-.5.5v12l.5.5h9l.5-.5V6.56zm-.274-1.14l-.58.58L8 3.854 10.146 6l.58-.58z" clip-rule="evenodd"/> | |||
<path fill="#75BEFF" fill-rule="evenodd" d="M10.146 6L8 3.854v-.708L10.146 1l.708.707L9.56 3h3a2.5 2.5 0 0 1 0 5h-.5V7h.5a1.5 1.5 0 0 0 0-3h-3l1.293 1.293-.708.707z" clip-rule="evenodd"/> | |||
</svg> |
@ -0,0 +1,5 @@ | |||
<!--<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"> <g fill-rule="evenodd" clip-path="url(#clip0)" clip-rule="evenodd"> <path fill="#424242" d="M1 2.5l.5-.5h5.7l.3.1 3.4 3.5.1.4v2.44l-.854-.854-.146.146V7H6V3H2v11h6.732l1 1H1.5l-.5-.5v-12zM11 11v1h-1v-1h1zm-1-.44l.854-.853L10.146 9 10 9.146v1.415zm0 3.294l.146.146.708-.707-.854-.854v1.415zM7 3l2.903 3H7V3z"/> <path fill="#007ACC" d="M10.146 14L8 11.854v-.707L10.146 9l.708.707L9.56 11h3a2.5 2.5 0 0 1 0 5h-.5v-1h.5a1.5 1.5 0 1 0 0-3h-3l1.293 1.293-.708.707z"/> </g> <defs> <clipPath id="clip0"> <path fill="#fff" d="M0 0h16v16H0z"/> </clipPath> </defs> </svg>--> | |||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"> | |||
<path fill="#424242" fill-rule="evenodd" d="M11 6.56l-.854.854L10 7.268V14H2V3h4v4h3.732l-1-1H7V2.732l.565-.565L7.5 2.1 7.2 2H1.5l-.5.5v12l.5.5h9l.5-.5V6.56zm-.274-1.14l-.58.58L8 3.854 10.146 6l.58-.58z" clip-rule="evenodd"/> | |||
<path fill="#007ACC" fill-rule="evenodd" d="M10.146 6L8 3.854v-.708L10.146 1l.708.707L9.56 3h3a2.5 2.5 0 0 1 0 5h-.5V7h.5a1.5 1.5 0 0 0 0-3h-3l1.293 1.293-.708.707z" clip-rule="evenodd"/> | |||
</svg> |
@ -0,0 +1,65 @@ | |||
'use strict'; | |||
import { Range, TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; | |||
import { FileAnnotationType } from '../configuration'; | |||
import { Container } from '../container'; | |||
import { GitUri } from '../git/gitService'; | |||
import { Logger } from '../logger'; | |||
import { Messages } from '../messages'; | |||
import { ActiveEditorCommand, command, Commands, getCommandUri, openEditor } from './common'; | |||
export interface OpenRevisionFileCommandArgs { | |||
uri?: Uri; | |||
line?: number; | |||
showOptions?: TextDocumentShowOptions; | |||
annotationType?: FileAnnotationType; | |||
} | |||
@command() | |||
export class OpenRevisionFileCommand extends ActiveEditorCommand { | |||
constructor() { | |||
super(Commands.OpenRevisionFile); | |||
} | |||
async execute(editor: TextEditor, uri?: Uri, args: OpenRevisionFileCommandArgs = {}) { | |||
args = { ...args }; | |||
if (args.line === undefined) { | |||
args.line = editor == null ? 0 : editor.selection.active.line; | |||
} | |||
try { | |||
if (args.uri == null) { | |||
uri = getCommandUri(uri, editor); | |||
if (uri == null) return undefined; | |||
} | |||
else { | |||
uri = args.uri; | |||
} | |||
args.uri = await GitUri.fromUri(uri); | |||
if (GitUri.is(args.uri) && args.uri.sha) { | |||
const commit = await Container.git.getCommit(args.uri.repoPath!, args.uri.sha); | |||
args.uri = | |||
commit !== undefined && commit.status === 'D' | |||
? GitUri.toRevisionUri(commit.previousSha!, commit.previousUri.fsPath, commit.repoPath) | |||
: GitUri.toRevisionUri(args.uri); | |||
} | |||
if (args.line !== undefined && args.line !== 0) { | |||
if (args.showOptions === undefined) { | |||
args.showOptions = {}; | |||
} | |||
args.showOptions.selection = new Range(args.line, 0, args.line, 0); | |||
} | |||
const e = await openEditor(args.uri, { ...args.showOptions, rethrow: true }); | |||
if (args.annotationType === undefined) return e; | |||
return Container.fileAnnotations.show(e, args.annotationType, args.line); | |||
} | |||
catch (ex) { | |||
Logger.error(ex, 'OpenRevisionFileCommand'); | |||
return Messages.showGenericErrorMessage('Unable to open file revision'); | |||
} | |||
} | |||
} |