lineWarningLength -> validationProvider

This commit is contained in:
Joao Moreno
2018-01-26 16:43:53 +01:00
parent 786ea020f7
commit 888f74495d
13 changed files with 219 additions and 71 deletions

View File

@@ -601,6 +601,7 @@ export function createApiFactory(
StatusBarAlignment: extHostTypes.StatusBarAlignment,
SymbolInformation: extHostTypes.SymbolInformation,
SymbolKind: extHostTypes.SymbolKind,
SourceControlInputBoxValidationType: extHostTypes.SourceControlInputBoxValidationType,
TextDocumentSaveReason: extHostTypes.TextDocumentSaveReason,
TextEdit: extHostTypes.TextEdit,
TextEditorCursorStyle: TextEditorCursorStyle,

View File

@@ -431,7 +431,7 @@ export interface MainThreadSCMShape extends IDisposable {
$setInputBoxValue(sourceControlHandle: number, value: string): void;
$setInputBoxPlaceholder(sourceControlHandle: number, placeholder: string): void;
$setLineWarningLength(sourceControlHandle: number, lineWarningLength: number): void;
$setValidationProviderIsEnabled(sourceControlHandle: number, enabled: boolean): void;
}
export type DebugSessionUUID = string;
@@ -693,6 +693,7 @@ export interface ExtHostSCMShape {
$provideOriginalResource(sourceControlHandle: number, uri: string): TPromise<string>;
$onInputBoxValueChange(sourceControlHandle: number, value: string): TPromise<void>;
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): TPromise<void>;
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): TPromise<[string, number] | undefined>;
}
export interface ExtHostTaskShape {

View File

@@ -140,15 +140,20 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
this._placeholder = placeholder;
}
private _lineWarningLength: number | undefined;
private _validationProvider: vscode.SourceControlInputBoxValidationProvider;
get lineWarningLength(): number | undefined {
return this._lineWarningLength;
get validationProvider(): vscode.SourceControlInputBoxValidationProvider {
return this._validationProvider;
}
set lineWarningLength(lineWarningLength: number) {
this._proxy.$setLineWarningLength(this._sourceControlHandle, lineWarningLength);
this._lineWarningLength = lineWarningLength;
set validationProvider(provider: vscode.SourceControlInputBoxValidationProvider) {
if (!provider || typeof provider.validateInput !== 'function') {
console.warn('INVALID SCM input box validation provider');
return;
}
this._validationProvider = provider;
this._proxy.$setValidationProviderIsEnabled(this._sourceControlHandle, true);
}
constructor(private _proxy: MainThreadSCMShape, private _sourceControlHandle: number) {
@@ -567,4 +572,22 @@ export class ExtHostSCM implements ExtHostSCMShape {
await group.$executeResourceCommand(handle);
}
async $validateInput(sourceControlHandle: number, value: string, cursorPosition: number): TPromise<[string, number] | undefined> {
this.logService.trace('ExtHostSCM#$validateInput', sourceControlHandle);
const sourceControl = this._sourceControls.get(sourceControlHandle);
if (!sourceControl) {
return TPromise.as(undefined);
}
const result = await sourceControl.inputBox.validationProvider.validateInput(value, cursorPosition);
if (!result) {
return TPromise.as(undefined);
}
return [result.message, result.type];
}
}

View File

@@ -1200,6 +1200,12 @@ export enum ColorFormat {
HSL = 2
}
export enum SourceControlInputBoxValidationType {
Error = 0,
Warning = 1,
Information = 2
}
export enum TaskRevealKind {
Always = 1,