Ver código fonte

Changes file alt+right to be a diff on commit details quick pick

Changes file alt+right to be a diff on repo status quick pick
main
Eric Amodio 7 anos atrás
pai
commit
d35074ecf8
6 arquivos alterados com 58 adições e 22 exclusões
  1. +3
    -2
      src/commands/diffWithPrevious.ts
  2. +4
    -4
      src/git/gitUri.ts
  3. +2
    -2
      src/gitService.ts
  4. +29
    -5
      src/quickPicks/commitDetails.ts
  5. +6
    -6
      src/quickPicks/common.ts
  6. +14
    -3
      src/quickPicks/repoStatus.ts

+ 3
- 2
src/commands/diffWithPrevious.ts Ver arquivo

@ -3,6 +3,7 @@ import { Iterables } from '../system';
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { BuiltInCommands } from '../constants';
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
import { GitCommit, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import * as moment from 'moment';
@ -27,13 +28,13 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
args.line = args.line || (editor === undefined ? 0 : editor.selection.active.line);
if (args.commit === undefined || args.range !== undefined) {
if (args.commit === undefined || (args.commit.type !== 'file') || args.range !== undefined) {
const gitUri = await GitUri.fromUri(uri, this.git);
try {
// If the sha is missing or the file is uncommitted, treat it as a DiffWithWorking
if (gitUri.sha === undefined && await this.git.isFileUncommitted(gitUri)) {
return commands.executeCommand(Commands.DiffWithWorking, uri);
return commands.executeCommand(Commands.DiffWithWorking, uri, { showOptions: args.showOptions } as DiffWithWorkingCommandArgs);
}
const sha = args.commit === undefined ? gitUri.sha : args.commit.sha;

+ 4
- 4
src/git/gitUri.ts Ver arquivo

@ -1,7 +1,7 @@
'use strict';
import { Uri } from 'vscode';
import { DocumentSchemes } from '../constants';
import { GitCommit, GitService, IGitStatusFile } from '../gitService';
import { GitService, IGitStatusFile } from '../gitService';
import * as path from 'path';
export class GitUri extends Uri {
@ -93,9 +93,9 @@ export class GitUri extends Uri {
}
static fromFileStatus(status: IGitStatusFile, repoPath: string, original?: boolean): GitUri;
static fromFileStatus(status: IGitStatusFile, commit: GitCommit, original?: boolean): GitUri;
static fromFileStatus(status: IGitStatusFile, repoPathOrCommit: string | GitCommit, original: boolean = false): GitUri {
const repoPath = repoPathOrCommit instanceof GitCommit ? repoPathOrCommit.repoPath : repoPathOrCommit;
static fromFileStatus(status: IGitStatusFile, commit: IGitCommitInfo, original?: boolean): GitUri;
static fromFileStatus(status: IGitStatusFile, repoPathOrCommit: string | IGitCommitInfo, original: boolean = false): GitUri {
const repoPath = typeof repoPathOrCommit === 'string' ? repoPathOrCommit : repoPathOrCommit.repoPath;
const uri = Uri.file(path.resolve(repoPath, original ? status.originalFileName || status.fileName : status.fileName));
return new GitUri(uri, repoPathOrCommit);
}

+ 2
- 2
src/gitService.ts Ver arquivo

@ -5,7 +5,7 @@ import { CommandContext, setCommandContext } from './commands';
import { CodeLensVisibility, IConfig } from './configuration';
import { DocumentSchemes, ExtensionKey } from './constants';
import { Git, GitBlameParser, GitBranch, GitCommit, GitLogCommit, GitLogParser, GitRemote, GitStashParser, GitStatusFile, GitStatusParser, IGit, IGitAuthor, IGitBlame, IGitBlameLine, IGitBlameLines, IGitLog, IGitStash, IGitStatus } from './git/git';
import { IGitUriData, GitUri } from './git/gitUri';
import { GitUri, IGitCommitInfo, IGitUriData } from './git/gitUri';
import { GitCodeLensProvider } from './gitCodeLensProvider';
import { Logger } from './logger';
import * as fs from 'fs';
@ -13,7 +13,7 @@ import * as ignore from 'ignore';
import * as moment from 'moment';
import * as path from 'path';
export { GitUri };
export { GitUri, IGitCommitInfo };
export * from './git/models/models';
export { getNameFromRemoteResource, RemoteResource, RemoteProvider } from './git/remotes/provider';
export * from './git/gitContextTracker';

+ 29
- 5
src/quickPicks/commitDetails.ts Ver arquivo

@ -1,15 +1,16 @@
'use strict';
import { Arrays, Iterables } from '../system';
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffDirectoryCommandCommandArgs, Keyboard, KeyNoopCommand, ShowQuickCommitDetailsCommandArgs, StashApplyCommandArgs, StashDeleteCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem } from './common';
import { getGitStatusIcon, GitCommit, GitLogCommit, GitService, GitStashCommit, GitStatusFileStatus, GitUri, IGitLog, IGitStatusFile, RemoteResource } from '../gitService';
import { commands, QuickPickOptions, TextDocumentShowOptions, Uri, window } from 'vscode';
import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffDirectoryCommandCommandArgs, DiffWithPreviousCommandArgs, Keyboard, KeyNoopCommand, Keys, ShowQuickCommitDetailsCommandArgs, StashApplyCommandArgs, StashDeleteCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem, QuickPickItem } from './common';
import { getGitStatusIcon, GitCommit, GitLogCommit, GitService, GitStashCommit, GitStatusFileStatus, GitUri, IGitCommitInfo, IGitLog, IGitStatusFile, RemoteResource } from '../gitService';
import { OpenRemotesCommandQuickPickItem } from './remotes';
import * as moment from 'moment';
import * as path from 'path';
export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickItem {
private commit: GitCommit;
fileName: string;
gitUri: GitUri;
sha: string;
@ -44,12 +45,32 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
description: description
});
this.commit = commit;
this.fileName = status.fileName;
this.gitUri = GitUri.fromFileStatus(status, commit.repoPath);
this.gitUri = GitUri.fromFileStatus(status, {
fileName: status.fileName,
repoPath: commit.repoPath,
sha: commit.sha,
originalFileName: status.originalFileName
} as IGitCommitInfo);
this.sha = sha;
this.shortSha = shortSha;
this.status = status.status;
}
onDidPressKey(key: Keys): Promise<{} | undefined> {
if (this.commit.previousSha === undefined) return super.onDidPressKey(key);
return commands.executeCommand(Commands.DiffWithPrevious,
this.gitUri,
{
commit: this.commit,
showOptions: {
preserveFocus: true,
preview: false
} as TextDocumentShowOptions
} as DiffWithPreviousCommandArgs) as Promise<{} | undefined>;
}
}
export class OpenCommitFilesCommandQuickPickItem extends OpenFilesCommandQuickPickItem {
@ -288,6 +309,9 @@ export class CommitDetailsQuickPick {
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => {
scope.setKeyCommand('right', item);
if (typeof item.onDidSelect === 'function') {
item.onDidSelect();
}
}
} as QuickPickOptions);

+ 6
- 6
src/quickPicks/common.ts Ver arquivo

@ -120,12 +120,12 @@ export class OpenFileCommandQuickPickItem extends CommandQuickPickItem {
return openEditor(this.uri, options);
}
onDidSelect(): Promise<{} | undefined> {
return this.execute({
preserveFocus: true,
preview: true
});
}
// onDidSelect(): Promise<{} | undefined> {
// return this.execute({
// preserveFocus: true,
// preview: true
// });
// }
onDidPressKey(key: Keys): Promise<{} | undefined> {
return this.execute({

+ 14
- 3
src/quickPicks/repoStatus.ts Ver arquivo

@ -1,8 +1,8 @@
'use strict';
import { Iterables } from '../system';
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard, OpenChangedFilesCommandArgs, ShowQuickBranchHistoryCommandArgs, ShowQuickRepoStatusCommandArgs, ShowQuickStashListCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem } from './common';
import { commands, QuickPickOptions, TextDocumentShowOptions, Uri, window } from 'vscode';
import { Commands, DiffWithWorkingCommandArgs, Keyboard, Keys, OpenChangedFilesCommandArgs, ShowQuickBranchHistoryCommandArgs, ShowQuickRepoStatusCommandArgs, ShowQuickStashListCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem, QuickPickItem } from './common';
import { GitService, GitStatusFile, GitUri, IGitStatus } from '../gitService';
import * as path from 'path';
@ -25,6 +25,17 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick
description: description
});
}
onDidPressKey(key: Keys): Promise<{} | undefined> {
return commands.executeCommand(Commands.DiffWithWorking,
this.uri,
{
showOptions: {
preserveFocus: true,
preview: false
} as TextDocumentShowOptions
} as DiffWithWorkingCommandArgs) as Promise<{} | undefined>;
}
}
export class OpenStatusFilesCommandQuickPickItem extends CommandQuickPickItem {

Carregando…
Cancelar
Salvar