提交 63da9825 编写于 作者: J Joao Moreno

Revert "Revert "Merge branch 'pr/60051'""

This reverts commit fb1ed792.
上级 2142a3d0
......@@ -570,6 +570,7 @@ export class Repository implements Disposable {
const root = Uri.file(repository.root);
this._sourceControl = scm.createSourceControl('git', 'Git', root);
this._sourceControl.inputBox.placeholder = localize('commitMessage', "Message (press {0} to commit)");
this._sourceControl.inputBox.visible = false;
this._sourceControl.acceptInputCommand = { command: 'git.commitWithInput', title: localize('commit', "Commit"), arguments: [this._sourceControl] };
this._sourceControl.quickDiffProvider = this;
this._sourceControl.inputBox.validateInput = this.validateInput.bind(this);
......
......@@ -724,6 +724,21 @@ declare module 'vscode' {
//#endregion
//#region Joao: SCM Input Box
/**
* Represents the input box in the Source Control viewlet.
*/
export interface SourceControlInputBox {
/**
* Whether the input box is visible.
*/
visible: boolean;
}
//#endregion
//#region Comments
/**
* Comments provider related APIs are still in early stages, they may be changed significantly during our API experiments.
......
......@@ -395,6 +395,16 @@ export class MainThreadSCM implements MainThreadSCMShape {
repository.input.placeholder = placeholder;
}
$setInputBoxVisibility(sourceControlHandle: number, visible: boolean): void {
const repository = this._repositories[sourceControlHandle];
if (!repository) {
return;
}
repository.input.visible = visible;
}
$setValidationProviderIsEnabled(sourceControlHandle: number, enabled: boolean): void {
const repository = this._repositories[sourceControlHandle];
......
......@@ -579,6 +579,7 @@ export interface MainThreadSCMShape extends IDisposable {
$setInputBoxValue(sourceControlHandle: number, value: string): void;
$setInputBoxPlaceholder(sourceControlHandle: number, placeholder: string): void;
$setInputBoxVisibility(sourceControlHandle: number, visible: boolean): void;
$setValidationProviderIsEnabled(sourceControlHandle: number, enabled: boolean): void;
}
......
......@@ -198,6 +198,18 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
this._proxy.$setValidationProviderIsEnabled(this._sourceControlHandle, !!fn);
}
private _visible: boolean = true;
get visible(): boolean {
return this._visible;
}
set visible(visible: boolean | undefined) {
visible = !!visible;
this._visible = visible;
this._proxy.$setInputBoxVisibility(this._sourceControlHandle, visible);
}
constructor(private _extension: IExtensionDescription, private _proxy: MainThreadSCMShape, private _sourceControlHandle: number) {
// noop
}
......
......@@ -137,12 +137,12 @@
}
.scm-viewlet .scm-editor {
box-sizing: border-box;
padding: 5px 9px 5px 16px;
}
.scm-viewlet .scm-editor {
box-sizing: border-box;
padding: 5px 9px 5px 16px;
.scm-viewlet .scm-editor.hidden {
display: none;
}
.scm-viewlet .scm-editor > .monaco-inputbox {
......
......@@ -11,7 +11,7 @@ import { domEvent, stop } from 'vs/base/browser/event';
import { basename } from 'vs/base/common/paths';
import { IDisposable, dispose, combinedDisposable, Disposable, toDisposable } from 'vs/base/common/lifecycle';
import { PanelViewlet, ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
import { append, $, addClass, toggleClass, trackFocus, Dimension, addDisposableListener } from 'vs/base/browser/dom';
import { append, $, addClass, toggleClass, trackFocus, Dimension, addDisposableListener, removeClass } from 'vs/base/browser/dom';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { List } from 'vs/base/browser/ui/list/listWidget';
import { IListVirtualDelegate, IListRenderer, IListContextMenuEvent, IListEvent } from 'vs/base/browser/ui/list/list';
......@@ -865,6 +865,10 @@ export class RepositoryPanel extends ViewletPanel {
this.updateInputBox();
// Input box visibility
this.repository.input.onDidChangeVisibility(this.updateInputBoxVisibility, this, this.disposables);
this.updateInputBoxVisibility();
// List
this.listContainer = append(container, $('.scm-status.show-file-icons'));
......@@ -918,21 +922,35 @@ export class RepositoryPanel extends ViewletPanel {
}
this.cachedHeight = height;
this.inputBox.layout();
const editorHeight = this.inputBox.height;
const listHeight = height - (editorHeight + 12 /* margin */);
this.listContainer.style.height = `${listHeight}px`;
this.list.layout(listHeight);
if (this.repository.input.visible) {
removeClass(this.inputBoxContainer, 'hidden');
this.inputBox.layout();
const editorHeight = this.inputBox.height;
const listHeight = height - (editorHeight + 12 /* margin */);
this.listContainer.style.height = `${listHeight}px`;
this.list.layout(listHeight);
toggleClass(this.inputBoxContainer, 'scroll', editorHeight >= 134);
toggleClass(this.inputBoxContainer, 'scroll', editorHeight >= 134);
} else {
addClass(this.inputBoxContainer, 'hidden');
removeClass(this.inputBoxContainer, 'scroll');
this.listContainer.style.height = `${height}px`;
this.list.layout(height);
}
}
focus(): void {
super.focus();
if (this.isExpanded()) {
this.inputBox.focus();
if (this.repository.input.visible) {
this.inputBox.focus();
} else {
this.list.domFocus();
}
}
}
......@@ -991,13 +1009,19 @@ export class RepositoryPanel extends ViewletPanel {
}
private updateInputBox(): void {
if (typeof this.repository.provider.commitTemplate === 'undefined' || this.inputBox.value) {
if (typeof this.repository.provider.commitTemplate === 'undefined' || !this.repository.input.visible || this.inputBox.value) {
return;
}
this.inputBox.value = this.repository.provider.commitTemplate;
}
private updateInputBoxVisibility(): void {
if (this.cachedHeight) {
this.layoutBody(this.cachedHeight);
}
}
dispose(): void {
this.visibilityDisposables = dispose(this.visibilityDisposables);
super.dispose();
......
......@@ -90,6 +90,9 @@ export interface ISCMInput {
validateInput: IInputValidator;
readonly onDidChangeValidateInput: Event<void>;
visible: boolean;
readonly onDidChangeVisibility: Event<boolean>;
}
export interface ISCMRepository extends IDisposable {
......
......@@ -40,6 +40,20 @@ class SCMInput implements ISCMInput {
private _onDidChangePlaceholder = new Emitter<string>();
get onDidChangePlaceholder(): Event<string> { return this._onDidChangePlaceholder.event; }
private _visible = true;
get visible(): boolean {
return this._visible;
}
set visible(visible: boolean) {
this._visible = visible;
this._onDidChangeVisibility.fire(visible);
}
private _onDidChangeVisibility = new Emitter<boolean>();
get onDidChangeVisibility(): Event<boolean> { return this._onDidChangeVisibility.event; }
private _validateInput: IInputValidator = () => TPromise.as(undefined);
get validateInput(): IInputValidator {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册