mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
Git - remove git.experimental.inputValidation setting (#205550)
* Git - remove git.experimental.inputValidation setting * Fix compilation error * Fix migration code
This commit is contained in:
@@ -975,10 +975,9 @@ export class Repository implements Disposable {
|
||||
this.setCountBadge();
|
||||
}
|
||||
|
||||
validateInput(text: string, position: number): SourceControlInputBoxValidation | undefined {
|
||||
let tooManyChangesWarning: SourceControlInputBoxValidation | undefined;
|
||||
validateInput(text: string, _: number): SourceControlInputBoxValidation | undefined {
|
||||
if (this.isRepositoryHuge) {
|
||||
tooManyChangesWarning = {
|
||||
return {
|
||||
message: l10n.t('Too many changes were detected. Only the first {0} changes will be shown below.', this.isRepositoryHuge.limit),
|
||||
type: SourceControlInputBoxValidationType.Warning
|
||||
};
|
||||
@@ -993,59 +992,7 @@ export class Repository implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
const config = workspace.getConfiguration('git');
|
||||
const setting = config.get<'always' | 'warn' | 'off'>('inputValidation');
|
||||
|
||||
if (setting === 'off') {
|
||||
return tooManyChangesWarning;
|
||||
}
|
||||
|
||||
if (/^\s+$/.test(text)) {
|
||||
return {
|
||||
message: l10n.t('Current commit message only contains whitespace characters'),
|
||||
type: SourceControlInputBoxValidationType.Warning
|
||||
};
|
||||
}
|
||||
|
||||
let lineNumber = 0;
|
||||
let start = 0;
|
||||
let match: RegExpExecArray | null;
|
||||
const regex = /\r?\n/g;
|
||||
|
||||
while ((match = regex.exec(text)) && position > match.index) {
|
||||
start = match.index + match[0].length;
|
||||
lineNumber++;
|
||||
}
|
||||
|
||||
const end = match ? match.index : text.length;
|
||||
|
||||
const line = text.substring(start, end);
|
||||
|
||||
let threshold = config.get<number>('inputValidationLength', 50);
|
||||
|
||||
if (lineNumber === 0) {
|
||||
const inputValidationSubjectLength = config.get<number | null>('inputValidationSubjectLength', null);
|
||||
|
||||
if (inputValidationSubjectLength !== null) {
|
||||
threshold = inputValidationSubjectLength;
|
||||
}
|
||||
}
|
||||
|
||||
if (line.length <= threshold) {
|
||||
if (setting !== 'always') {
|
||||
return tooManyChangesWarning;
|
||||
}
|
||||
|
||||
return {
|
||||
message: l10n.t('{0} characters left in current line', threshold - line.length),
|
||||
type: SourceControlInputBoxValidationType.Information
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
message: l10n.t('{0} characters over {1} in current line', line.length - threshold, threshold),
|
||||
type: SourceControlInputBoxValidationType.Warning
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user