Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCM] Fix SCM status bar commands #6236

Merged
merged 1 commit into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import { IJSONSchema, IJSONSchemaSnippet } from '@theia/core/lib/common/json-sch
import { DebuggerDescription } from '@theia/debug/lib/common/debug-service';
import { DebugProtocol } from 'vscode-debugprotocol';
import { SymbolInformation } from 'vscode-languageserver-types';
import { ScmCommand } from '@theia/scm/lib/browser/scm-provider';
import { ArgumentProcessor } from '../plugin/command-registry';
import { MaybePromise } from '@theia/core/lib/common/types';
import { QuickOpenItem, QuickOpenItemOptions } from '@theia/core/lib/common/quick-open-model';
Expand Down Expand Up @@ -607,8 +606,8 @@ export interface SourceControlProviderFeatures {
hasQuickDiffProvider?: boolean;
count?: number;
commitTemplate?: string;
acceptInputCommand?: ScmCommand;
statusBarCommands?: ScmCommand[];
acceptInputCommand?: Command;
statusBarCommands?: Command[];
}

export interface SourceControlGroupFeatures {
Expand Down
16 changes: 14 additions & 2 deletions packages/plugin-ext/src/main/browser/scm-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,23 @@ export class PluginScmProvider implements ScmProvider {
}

get acceptInputCommand(): ScmCommand | undefined {
return this.features.acceptInputCommand;
const command = this.features.acceptInputCommand;
if (command) {
const scmCommand: ScmCommand = command;
scmCommand.command = command.id;
return command;
}
}

get statusBarCommands(): ScmCommand[] | undefined {
return this.features.statusBarCommands;
const commands = this.features.statusBarCommands;
if (commands) {
return commands.map(command => {
const scmCommand: ScmCommand = command;
scmCommand.command = command.id;
return scmCommand;
});
}
}

get count(): number | undefined {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/plugin/scm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { DisposableCollection, Disposable } from '@theia/core/lib/common/disposa
import { UriComponents } from '../common/uri-components';
import URI from '@theia/core/lib/common/uri';
import { CommandRegistryImpl } from './command-registry';
import { ScmCommand } from '@theia/scm/lib/browser/scm-provider';
import { Emitter } from '@theia/core/lib/common/event';
import { Command } from '../common/plugin-api-rpc-model';

export class ScmExtImpl implements ScmExt {
private handle: number = 0;
Expand Down Expand Up @@ -254,7 +254,7 @@ class SourceControlImpl implements theia.SourceControl {

this._statusBarCommands = statusBarCommands;

let safeStatusBarCommands: ScmCommand[] | undefined;
let safeStatusBarCommands: Command[] | undefined;
if (statusBarCommands) {
safeStatusBarCommands = statusBarCommands.map(statusBarCommand => this.commands.converter.toSafeCommand(statusBarCommand, this.toDisposeOnStatusBarCommands));
}
Expand Down
1 change: 1 addition & 0 deletions packages/scm/src/browser/scm-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export class ScmContribution extends AbstractViewContribution<ScmWidget> impleme
text: value.title,
tooltip: label + (value.tooltip ? ` - ${value.tooltip}` : ''),
command: value.command,
arguments: value.arguments,
alignment: StatusBarAlignment.LEFT,
priority: 100
}));
Expand Down