Browse Source

Fixes #366 - keybinding args changed 😢

main
Eric Amodio 6 years ago
parent
commit
07592c6d18
2 changed files with 12 additions and 7 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +11
    -7
      src/commands/common.ts

+ 1
- 0
CHANGELOG.md View File

@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Reworks GitLens menu contributions and configuration
### Fixed
- Fixes [#366](https://github.com/eamodio/vscode-gitlens/issues/366) - Running a GitLens command from a keybinding fails
- Fixes [#155](https://github.com/eamodio/vscode-gitlens/issues/155) - Navigating file diffs with `alt+,` gets stuck
- Fixes [#359](https://github.com/eamodio/vscode-gitlens/issues/359) - Show changes of an added file in the first commit
- Fixes issue where comparing previous revision during a merge/rebase conflict failed to show the correct contents

+ 11
- 7
src/commands/common.ts View File

@ -66,8 +66,12 @@ export enum Commands {
export function getCommandUri(uri?: Uri, editor?: TextEditor): Uri | undefined {
if (uri instanceof Uri) return uri;
if (editor === undefined || editor.document === undefined) return undefined;
return editor.document.uri;
if (editor == null) return undefined;
const document = editor.document;
if (document == null) return undefined;
return document.uri;
}
export interface CommandContextParsingOptions {
@ -123,19 +127,19 @@ export function isCommandViewContextWithRemote(context: CommandContext): context
export type CommandContext = CommandScmGroupsContext | CommandScmStatesContext | CommandUnknownContext | CommandUriContext | CommandViewContext;
function isScmResourceGroup(group: any): group is SourceControlResourceGroup {
if (group === undefined) return false;
if (group == null) return false;
return (group as SourceControlResourceGroup).id !== undefined && (group.handle !== undefined || (group as SourceControlResourceGroup).label !== undefined || (group as SourceControlResourceGroup).resourceStates !== undefined);
}
function isScmResourceState(state: any): state is SourceControlResourceState {
if (state === undefined) return false;
if (state == null) return false;
return (state as SourceControlResourceState).resourceUri !== undefined;
}
function isTextEditor(editor: any): editor is TextEditor {
if (editor === undefined) return false;
if (editor == null) return false;
return editor.id !== undefined && ((editor as TextEditor).edit !== undefined || (editor as TextEditor).document !== undefined);
}
@ -184,13 +188,13 @@ export abstract class Command extends Disposable {
let editor: TextEditor | undefined = undefined;
let firstArg = args[0];
if (options.editor && (firstArg === undefined || isTextEditor(firstArg))) {
if (options.editor && (firstArg == null || isTextEditor(firstArg))) {
editor = firstArg;
args = args.slice(1);
firstArg = args[0];
}
if (options.uri && (firstArg === undefined || firstArg instanceof Uri)) {
if (options.uri && (firstArg == null || firstArg instanceof Uri)) {
const [uri, ...rest] = args as [Uri, any];
return [{ command: command, type: 'uri', editor: editor, uri: uri }, rest];
}

Loading…
Cancel
Save