Git - remove git.experimental.inputValidation setting (#205550)

* Git - remove git.experimental.inputValidation setting

* Fix compilation error

* Fix migration code
This commit is contained in:
Ladislau Szomoru
2024-02-19 19:45:24 +01:00
committed by GitHub
parent 248c585f02
commit 9b0d74345c
4 changed files with 33 additions and 72 deletions

View File

@@ -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;
}
/**