mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
lineWarningLength -> validationProvider
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1200,6 +1200,12 @@ export enum ColorFormat {
|
||||
HSL = 2
|
||||
}
|
||||
|
||||
export enum SourceControlInputBoxValidationType {
|
||||
Error = 0,
|
||||
Warning = 1,
|
||||
Information = 2
|
||||
}
|
||||
|
||||
export enum TaskRevealKind {
|
||||
Always = 1,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user