mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-15 10:58:36 -05:00
Fixes 'Compare with *' commands failing w/ no active editor
This commit is contained in:
@@ -1,26 +1,26 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { Commands, EditorCommand } from './commands';
|
import { ActiveEditorCommand, Commands } from './commands';
|
||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export class DiffLineWithPreviousCommand extends EditorCommand {
|
export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
|
||||||
|
|
||||||
constructor(private git: GitProvider) {
|
constructor(private git: GitProvider) {
|
||||||
super(Commands.DiffLineWithPrevious);
|
super(Commands.DiffLineWithPrevious);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(editor: TextEditor): Promise<any>;
|
async execute(editor: TextEditor): Promise<any>;
|
||||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri: Uri): Promise<any>;
|
async execute(editor: TextEditor, uri: Uri): Promise<any>;
|
||||||
async execute(editor: TextEditor, edit?: TextEditorEdit, uri?: Uri, commit?: GitCommit, line?: number): Promise<any> {
|
async execute(editor: TextEditor, uri?: Uri, commit?: GitCommit, line?: number): Promise<any> {
|
||||||
if (!(uri instanceof Uri)) {
|
if (!(uri instanceof Uri)) {
|
||||||
if (!editor.document) return undefined;
|
if (!editor || !editor.document) return undefined;
|
||||||
uri = editor.document.uri;
|
uri = editor.document.uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = line || editor.selection.active.line;
|
line = line ||(editor && editor.selection.active.line) || 0;
|
||||||
let gitUri = GitUri.fromUri(uri, this.git);
|
let gitUri = GitUri.fromUri(uri, this.git);
|
||||||
|
|
||||||
if (!commit || GitProvider.isUncommitted(commit.sha)) {
|
if (!commit || GitProvider.isUncommitted(commit.sha)) {
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { Commands, EditorCommand } from './commands';
|
import { ActiveEditorCommand, Commands } from './commands';
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
export class DiffLineWithWorkingCommand extends EditorCommand {
|
export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
|
||||||
|
|
||||||
constructor(private git: GitProvider) {
|
constructor(private git: GitProvider) {
|
||||||
super(Commands.DiffLineWithWorking);
|
super(Commands.DiffLineWithWorking);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(editor: TextEditor): Promise<any>;
|
async execute(editor: TextEditor): Promise<any>;
|
||||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri: Uri): Promise<any>;
|
async execute(editor: TextEditor, uri: Uri): Promise<any>;
|
||||||
async execute(editor: TextEditor, edit?: TextEditorEdit, uri?: Uri, commit?: GitCommit, line?: number): Promise<any> {
|
async execute(editor: TextEditor, uri?: Uri, commit?: GitCommit, line?: number): Promise<any> {
|
||||||
if (!(uri instanceof Uri)) {
|
if (!(uri instanceof Uri)) {
|
||||||
if (!editor.document) return undefined;
|
if (!editor || !editor.document) return undefined;
|
||||||
uri = editor.document.uri;
|
uri = editor.document.uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = line || editor.selection.active.line;
|
line = line || (editor && editor.selection.active.line) || 0;
|
||||||
|
|
||||||
if (!commit || GitProvider.isUncommitted(commit.sha)) {
|
if (!commit || GitProvider.isUncommitted(commit.sha)) {
|
||||||
const gitUri = GitUri.fromUri(uri, this.git);
|
const gitUri = GitUri.fromUri(uri, this.git);
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { commands, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { commands, Range, TextEditor, Uri, window } from 'vscode';
|
||||||
import { Commands, EditorCommand } from './commands';
|
import { ActiveEditorCommand, Commands } from './commands';
|
||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export class DiffWithPreviousCommand extends EditorCommand {
|
export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
||||||
|
|
||||||
constructor(private git: GitProvider) {
|
constructor(private git: GitProvider) {
|
||||||
super(Commands.DiffWithPrevious);
|
super(Commands.DiffWithPrevious);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(editor: TextEditor): Promise<any>;
|
async execute(editor: TextEditor): Promise<any>;
|
||||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri: Uri): Promise<any>;
|
async execute(editor: TextEditor, uri: Uri): Promise<any>;
|
||||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri: Uri, commit: GitCommit, range?: Range): Promise<any>;
|
async execute(editor: TextEditor, uri: Uri, commit: GitCommit, range?: Range): Promise<any>;
|
||||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri: Uri, commit: GitCommit, line?: number): Promise<any>;
|
async execute(editor: TextEditor, uri: Uri, commit: GitCommit, line?: number): Promise<any>;
|
||||||
async execute(editor: TextEditor, edit?: TextEditorEdit, uri?: Uri, commit?: GitCommit, rangeOrLine?: Range | number): Promise<any> {
|
async execute(editor: TextEditor, uri?: Uri, commit?: GitCommit, rangeOrLine?: Range | number): Promise<any> {
|
||||||
if (!(uri instanceof Uri)) {
|
if (!(uri instanceof Uri)) {
|
||||||
if (!editor.document) return undefined;
|
if (!editor || !editor.document) return undefined;
|
||||||
uri = editor.document.uri;
|
uri = editor.document.uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
let line = editor.selection.active.line;
|
let line = (editor && editor.selection.active.line) || 0;
|
||||||
if (typeof rangeOrLine === 'number') {
|
if (typeof rangeOrLine === 'number') {
|
||||||
line = rangeOrLine || line;
|
line = rangeOrLine || line;
|
||||||
rangeOrLine = undefined;
|
rangeOrLine = undefined;
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { Commands, EditorCommand } from './commands';
|
import { ActiveEditorCommand, Commands } from './commands';
|
||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export class DiffWithWorkingCommand extends EditorCommand {
|
export class DiffWithWorkingCommand extends ActiveEditorCommand {
|
||||||
|
|
||||||
constructor(private git: GitProvider) {
|
constructor(private git: GitProvider) {
|
||||||
super(Commands.DiffWithWorking);
|
super(Commands.DiffWithWorking);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(editor: TextEditor): Promise<any>;
|
async execute(editor: TextEditor): Promise<any>;
|
||||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri: Uri): Promise<any>;
|
async execute(editor: TextEditor, uri: Uri): Promise<any>;
|
||||||
async execute(editor: TextEditor, edit?: TextEditorEdit, uri?: Uri, commit?: GitCommit, line?: number): Promise<any> {
|
async execute(editor: TextEditor, uri?: Uri, commit?: GitCommit, line?: number): Promise<any> {
|
||||||
if (!(uri instanceof Uri)) {
|
if (!(uri instanceof Uri)) {
|
||||||
if (!editor.document) return undefined;
|
if (!editor || !editor.document) return undefined;
|
||||||
uri = editor.document.uri;
|
uri = editor.document.uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = line || editor.selection.active.line;
|
line = line || (editor && editor.selection.active.line) || 0;
|
||||||
|
|
||||||
if (!commit || GitProvider.isUncommitted(commit.sha)) {
|
if (!commit || GitProvider.isUncommitted(commit.sha)) {
|
||||||
const gitUri = GitUri.fromUri(uri, this.git);
|
const gitUri = GitUri.fromUri(uri, this.git);
|
||||||
|
|||||||
Reference in New Issue
Block a user