This commit is contained in:
Joao Moreno 2018-09-18 11:20:21 +02:00
parent 59892edc6e
commit 8a620ab5b8
3 changed files with 10 additions and 6 deletions

View file

@ -1107,6 +1107,11 @@
"default": "warn",
"description": "%config.inputValidation%"
},
"git.inputValidationLength": {
"type": "number",
"default": 72,
"description": "%config.inputValidationLength%"
},
"git.detectSubmodules": {
"type": "boolean",
"scope": "resource",

View file

@ -66,7 +66,6 @@
"config.autoRepositoryDetection.openEditors": "Scan for parent folders of open files.",
"config.autorefresh": "Whether auto refreshing is enabled.",
"config.autofetch": "Whether auto fetching is enabled.",
"config.enableLongCommitWarning": "Whether long commit messages should be warned about.",
"config.confirmSync": "Confirm before synchronizing git repositories.",
"config.countBadge": "Controls the git badge counter.",
"config.countBadge.all": "Count all changes.",
@ -91,6 +90,7 @@
"config.showInlineOpenFileAction": "Controls whether to show an inline Open File action in the Git changes view.",
"config.showPushSuccessNotification": "Controls whether to show a notification when a push is successful.",
"config.inputValidation": "Controls when to show commit message input validation.",
"config.inputValidationLength": "Controls the commit message length threshold for showing a warning.",
"config.detectSubmodules": "Controls whether to automatically detect git submodules.",
"config.detectSubmodulesLimit": "Controls the limit of git submodules detected.",
"config.alwaysShowStagedChangesResourceGroup": "Always show the Staged Changes resource group.",

View file

@ -456,8 +456,6 @@ class ProgressManager {
export class Repository implements Disposable {
private static readonly InputValidationLength = 72;
private _onDidChangeRepository = new EventEmitter<Uri>();
readonly onDidChangeRepository: Event<Uri> = this._onDidChangeRepository.event;
@ -669,19 +667,20 @@ export class Repository implements Disposable {
end = match ? match.index : text.length;
const line = text.substring(start, end);
const threshold = Math.max(config.get<number>('inputValidationLength') || 72, 0) || 72;
if (line.length <= Repository.InputValidationLength) {
if (line.length <= threshold) {
if (setting !== 'always') {
return;
}
return {
message: localize('commitMessageCountdown', "{0} characters left in current line", Repository.InputValidationLength - line.length),
message: localize('commitMessageCountdown', "{0} characters left in current line", threshold - line.length),
type: SourceControlInputBoxValidationType.Information
};
} else {
return {
message: localize('commitMessageWarning', "{0} characters over {1} in current line", line.length - Repository.InputValidationLength, Repository.InputValidationLength),
message: localize('commitMessageWarning', "{0} characters over {1} in current line", line.length - threshold, threshold),
type: SourceControlInputBoxValidationType.Warning
};
}