Ver a proveniência

Closes #236 - adds open working file

main
Eric Amodio há 7 anos
ascendente
cometimento
b254d7f96e
10 ficheiros alterados com 104 adições e 7 eliminações
  1. +4
    -0
      CHANGELOG.md
  2. +2
    -0
      README.md
  3. +4
    -0
      images/dark/open-file.svg
  4. +4
    -0
      images/light/open-file.svg
  5. +18
    -0
      package.json
  6. +2
    -0
      src/commands.ts
  7. +1
    -0
      src/commands/common.ts
  8. +55
    -0
      src/commands/openWorkingFile.ts
  9. +1
    -0
      src/constants.ts
  10. +13
    -7
      src/git/gitContextTracker.ts

+ 4
- 0
CHANGELOG.md Ver ficheiro

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Added
- Adds `Open Working File` command (`gitlens.openWorkingFile`) - opens the working file for the active file revision -- closes [#236](https://github.com/eamodio/vscode-gitlens/issues/236)
## [7.1.0-beta] - 2017-12-20
### Changed
- Improves startup performance by ~65% (on my very fast PC) and reduces package size by over 75%

+ 2
- 0
README.md Ver ficheiro

@ -330,6 +330,8 @@ While GitLens is highly customizable and provides many [configuration settings](
- Adds a `Copy Commit Message to Clipboard` command (`gitlens.copyMessageToClipboard`) to copy the commit message of the active line to the clipboard or from the most recent commit to the current branch, if there is no active editor
- Adds a `Open Working File"` command (`gitlens.openWorkingFile`) to open the working file for the active file revision
- Adds a `Open Changes (with difftool)` command (`gitlens.externalDiff`) to the source control group and source control resource context menus to open the changes of a file or set of files with the configured git difftool
- Adds a `Open All Changes (with difftool)` command (`gitlens.externalDiffAll`) to open all working changes with the configured git difftool

+ 4
- 0
images/dark/open-file.svg Ver ficheiro

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<polygon fill="#C5C5C5" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/>'
<polygon fill="#ba7dd9" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/>
</svg>

+ 4
- 0
images/light/open-file.svg Ver ficheiro

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<polygon fill="#424242" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/>'
<polygon fill="#7d16bf" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/>
</svg>

+ 18
- 0
package.json Ver ficheiro

@ -1328,6 +1328,15 @@
"category": "GitLens"
},
{
"command": "gitlens.openWorkingFile",
"title": "Open Working File",
"category": "GitLens",
"icon": {
"dark": "images/dark/open-file.svg",
"light": "images/light/open-file.svg"
}
},
{
"command": "gitlens.stashApply",
"title": "Apply Stashed Changes",
"category": "GitLens"
@ -1733,6 +1742,10 @@
"when": "gitlens:activeHasRemote"
},
{
"command": "gitlens.openWorkingFile",
"when": "gitlens:activeIsRevision"
},
{
"command": "gitlens.stashApply",
"when": "gitlens:enabled"
},
@ -1959,6 +1972,11 @@
],
"editor/title": [
{
"command": "gitlens.openWorkingFile",
"when": "gitlens:activeIsRevision",
"group": "navigation@1"
},
{
"command": "gitlens.toggleFileBlame",
"alt": "gitlens.toggleFileRecentChanges",
"when": "gitlens:activeIsBlameable && !gitlens:annotationStatus && config.gitlens.advanced.menus.editorTitle.blame",

+ 2
- 0
src/commands.ts Ver ficheiro

@ -29,6 +29,7 @@ export * from './commands/openFileInRemote';
export * from './commands/openFileRevision';
export * from './commands/openInRemote';
export * from './commands/openRepoInRemote';
export * from './commands/openWorkingFile';
export * from './commands/resetSuppressedWarnings';
export * from './commands/showCommitSearch';
export * from './commands/showFileBlame';
@ -81,6 +82,7 @@ export function configureCommands(
context.subscriptions.push(new Commands.OpenFileRevisionCommand(annotationController));
context.subscriptions.push(new Commands.OpenInRemoteCommand());
context.subscriptions.push(new Commands.OpenRepoInRemoteCommand(git));
context.subscriptions.push(new Commands.OpenWorkingFileCommand(annotationController, git));
context.subscriptions.push(new Commands.ClearFileAnnotationsCommand(annotationController));
context.subscriptions.push(new Commands.ShowFileBlameCommand(annotationController));
context.subscriptions.push(new Commands.ShowLineBlameCommand(currentLineController));

+ 1
- 0
src/commands/common.ts Ver ficheiro

@ -31,6 +31,7 @@ export enum Commands {
OpenFileRevision = 'gitlens.openFileRevision',
OpenInRemote = 'gitlens.openInRemote',
OpenRepoInRemote = 'gitlens.openRepoInRemote',
OpenWorkingFile = 'gitlens.openWorkingFile',
ResetSuppressedWarnings = 'gitlens.resetSuppressedWarnings',
ShowCommitSearch = 'gitlens.showCommitSearch',
ShowFileBlame = 'gitlens.showFileBlame',

+ 55
- 0
src/commands/openWorkingFile.ts Ver ficheiro

@ -0,0 +1,55 @@
'use strict';
import { Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { AnnotationController, FileAnnotationType } from '../annotations/annotationController';
import { ActiveEditorCommand, Commands, getCommandUri, openEditor } from './common';
import { GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
export interface OpenWorkingFileCommandArgs {
uri?: Uri;
line?: number;
showOptions?: TextDocumentShowOptions;
annotationType?: FileAnnotationType;
}
export class OpenWorkingFileCommand extends ActiveEditorCommand {
constructor(
private readonly annotationController: AnnotationController,
private readonly git: GitService
) {
super(Commands.OpenWorkingFile);
}
async execute(editor: TextEditor, uri?: Uri, args: OpenWorkingFileCommandArgs = {}) {
args = { ...args };
if (args.line === undefined) {
args.line = editor === undefined ? 0 : editor.selection.active.line;
}
try {
if (args.uri === undefined) {
uri = getCommandUri(uri, editor);
if (uri === undefined) return undefined;
args.uri = await GitUri.fromUri(uri, this.git);
}
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);
if (args.annotationType === undefined) return e;
return this.annotationController.showAnnotations(e!, args.annotationType, args.line);
}
catch (ex) {
Logger.error(ex, 'OpenWorkingFileCommand');
return window.showErrorMessage(`Unable to open working file. See output channel for more details`);
}
}
}

+ 1
- 0
src/constants.ts Ver ficheiro

@ -29,6 +29,7 @@ export enum CommandContext {
ActiveHasRemote = 'gitlens:activeHasRemote',
ActiveIsBlameable = 'gitlens:activeIsBlameable',
ActiveFileIsTracked = 'gitlens:activeIsTracked',
ActiveIsRevision = 'gitlens:activeIsRevision',
AnnotationStatus = 'gitlens:annotationStatus',
CanToggleCodeLens = 'gitlens:canToggleCodeLens',
Enabled = 'gitlens:enabled',

+ 13
- 7
src/git/gitContextTracker.ts Ver ficheiro

@ -31,6 +31,7 @@ interface Context {
interface ContextState {
blameable?: boolean;
dirty: boolean;
revision?: boolean;
tracked?: boolean;
}
@ -147,7 +148,8 @@ export class GitContextTracker extends Disposable {
private async updateContext(reason: BlameabilityChangeReason, editor: TextEditor | undefined, force: boolean = false) {
try {
let tracked: boolean;
let revision = false;
let tracked = false;
if (force || this._context.editor !== editor) {
this._context.editor = editor;
this._context.repo = undefined;
@ -166,20 +168,24 @@ export class GitContextTracker extends Disposable {
}
this._context.state.dirty = editor.document.isDirty;
revision = !!this._context.uri.sha;
tracked = await this.git.isTracked(this._context.uri);
}
else {
this._context.uri = undefined;
this._context.state.dirty = false;
this._context.state.blameable = false;
tracked = false;
}
}
else {
// Since the tracked state could have changed, update it
tracked = this._context.uri !== undefined
? await this.git.isTracked(this._context.uri!)
: false;
// Since the revision or tracked state could have changed, update it
else if (this._context.uri !== undefined) {
revision = !!this._context.uri.sha;
tracked = await this.git.isTracked(this._context.uri);
}
if (this._context.state.revision !== revision) {
this._context.state.revision = revision;
setCommandContext(CommandContext.ActiveIsRevision, revision);
}
if (this._context.state.tracked !== tracked) {

Carregando…
Cancelar
Guardar