mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-10 05:28:19 -05:00
Set placeholder text in SourceControlInputBox
This commit is contained in:
@@ -385,6 +385,7 @@ export class Repository implements Disposable {
|
||||
const label = `${path.basename(repository.root)} (Git)`;
|
||||
|
||||
this._sourceControl = scm.createSourceControl('git', label);
|
||||
this._sourceControl.inputBox.placeholder = localize('commitMessage', "Message (press {0} to commit)", process.platform === 'darwin' ? 'Cmd+Enter' : 'Ctrl+Enter');
|
||||
this._sourceControl.acceptInputCommand = { command: 'git.commitWithInput', title: localize('commit', "Commit"), arguments: [this._sourceControl] };
|
||||
this._sourceControl.quickDiffProvider = this;
|
||||
this.disposables.push(this._sourceControl);
|
||||
|
||||
5
src/vs/vscode.d.ts
vendored
5
src/vs/vscode.d.ts
vendored
@@ -5326,6 +5326,11 @@ declare module 'vscode' {
|
||||
* Setter and getter for the contents of the input box.
|
||||
*/
|
||||
value: string;
|
||||
|
||||
/**
|
||||
* A string to show as place holder in the input box to guide the user.
|
||||
*/
|
||||
placeholder: string;
|
||||
}
|
||||
|
||||
interface QuickDiffProvider {
|
||||
|
||||
@@ -343,4 +343,14 @@ export class MainThreadSCM implements MainThreadSCMShape {
|
||||
|
||||
repository.input.value = value;
|
||||
}
|
||||
|
||||
$setInputBoxPlaceholder(sourceControlHandle: number, placeholder: string): void {
|
||||
const repository = this._repositories[sourceControlHandle];
|
||||
|
||||
if (!repository) {
|
||||
return;
|
||||
}
|
||||
|
||||
repository.input.placeholder = placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,6 +348,7 @@ export interface MainThreadSCMShape extends IDisposable {
|
||||
$unregisterGroup(sourceControlHandle: number, handle: number): void;
|
||||
|
||||
$setInputBoxValue(sourceControlHandle: number, value: string): void;
|
||||
$setInputBoxPlaceholder(sourceControlHandle: number, placeholder: string): void;
|
||||
}
|
||||
|
||||
export type DebugSessionUUID = string;
|
||||
|
||||
@@ -43,6 +43,17 @@ export class ExtHostSCMInputBox {
|
||||
return this._onDidChange.event;
|
||||
}
|
||||
|
||||
private _placeholder: string = '';
|
||||
|
||||
get placeholder(): string {
|
||||
return this._placeholder;
|
||||
}
|
||||
|
||||
set placeholder(placeholder: string) {
|
||||
this._proxy.$setInputBoxPlaceholder(this._sourceControlHandle, placeholder);
|
||||
this._placeholder = placeholder;
|
||||
}
|
||||
|
||||
constructor(private _proxy: MainThreadSCMShape, private _sourceControlHandle: number) {
|
||||
// noop
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { ViewSizing } from 'vs/base/browser/ui/splitview/splitview';
|
||||
import { IExtensionsViewlet, VIEWLET_ID as EXTENSIONS_VIEWLET_ID } from 'vs/workbench/parts/extensions/common/extensions';
|
||||
import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { domEvent } from 'vs/base/browser/event';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
@@ -307,15 +306,16 @@ class SourceControlView extends CollapsibleView {
|
||||
this.inputBoxContainer = append(container, $('.scm-editor'));
|
||||
|
||||
this.inputBox = new InputBox(this.inputBoxContainer, this.contextViewService, {
|
||||
placeholder: localize('commitMessage', "Message (press {0} to commit)", platform.isMacintosh ? 'Cmd+Enter' : 'Ctrl+Enter'),
|
||||
flexibleHeight: true
|
||||
});
|
||||
this.disposables.push(attachInputBoxStyler(this.inputBox, this.themeService));
|
||||
this.disposables.push(this.inputBox);
|
||||
|
||||
this.inputBox.value = this.repository.input.value;
|
||||
this.inputBox.setPlaceHolder(this.repository.input.placeholder);
|
||||
this.inputBox.onDidChange(value => this.repository.input.value = value, null, this.disposables);
|
||||
this.repository.input.onDidChange(value => this.inputBox.value = value, null, this.disposables);
|
||||
this.repository.input.onDidChangePlaceholder(placeholder => this.inputBox.setPlaceHolder(placeholder), null, this.disposables);
|
||||
this.disposables.push(this.inputBox.onDidHeightChange(() => this.layoutBody()));
|
||||
|
||||
chain(domEvent(this.inputBox.inputElement, 'keydown'))
|
||||
|
||||
@@ -58,6 +58,8 @@ export interface ISCMProvider extends IDisposable {
|
||||
export interface ISCMInput {
|
||||
value: string;
|
||||
readonly onDidChange: Event<string>;
|
||||
placeholder: string;
|
||||
readonly onDidChangePlaceholder: Event<string>;
|
||||
}
|
||||
|
||||
export interface ISCMRepository extends IDisposable {
|
||||
|
||||
@@ -24,6 +24,20 @@ class SCMInput implements ISCMInput {
|
||||
|
||||
private _onDidChange = new Emitter<string>();
|
||||
get onDidChange(): Event<string> { return this._onDidChange.event; }
|
||||
|
||||
private _placeholder = '';
|
||||
|
||||
get placeholder(): string {
|
||||
return this._placeholder;
|
||||
}
|
||||
|
||||
set placeholder(placeholder: string) {
|
||||
this._placeholder = placeholder;
|
||||
this._onDidChangePlaceholder.fire(placeholder);
|
||||
}
|
||||
|
||||
private _onDidChangePlaceholder = new Emitter<string>();
|
||||
get onDidChangePlaceholder(): Event<string> { return this._onDidChangePlaceholder.event; }
|
||||
}
|
||||
|
||||
class SCMRepository implements ISCMRepository {
|
||||
|
||||
Reference in New Issue
Block a user