diff --git a/extensions/git/package.json b/extensions/git/package.json index 06f15b32246..805783706c1 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -1173,18 +1173,16 @@ }, "git.inputValidationLength": { "type": "number", - "default": 50, + "default": 72, "description": "%config.inputValidationLength%" }, - "git.subjectValidationLength": { - "type": "number", - "default": 50, - "description": "%config.subjectValidationLength%" - }, - "git.bodyValidationLength": { - "type": "number", - "default": 72, - "description": "%config.bodyValidationLength%" + "git.inputValidationSubjectLength": { + "type": [ + "number", + "null" + ], + "default": null, + "description": "%config.inputValidationSubjectLength%" }, "git.detectSubmodules": { "type": "boolean", diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index ba137188489..4f749189fc7 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -98,8 +98,7 @@ "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.subjectValidationLength": "Controls the commit message subject length threshold for showing a warning.", - "config.bodyValidationLength": "Controls the commit message body length threshold for showing a warning.", + "config.inputValidationSubjectLength": "Controls the commit message subject length threshold for showing a warning. Unset it to inherit the value of `config.inputValidationLength`.", "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.", diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 38293ef98fa..6a57806ac12 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -647,31 +647,56 @@ export class Repository implements Disposable { }; } + let lineNumber = 0; let start = 0, end; let match: RegExpExecArray | null; const regex = /\r?\n/g; while ((match = regex.exec(text)) && position > match.index) { start = match.index + match[0].length; + lineNumber++; } end = match ? match.index : text.length; const line = text.substring(start, end); - const subjectThreshold = Math.max(config.get('inputValidationLength') || 50, config.get('subjectValidationLength') || 50, 0) || 50; - if (line.length <= subjectThreshold) { + let threshold = config.get('inputValidationLength', 50); + + if (lineNumber === 0) { + const inputValidationSubjectLength = config.get('inputValidationSubjectLength', null); + + if (inputValidationSubjectLength !== null) { + threshold = inputValidationSubjectLength; + } + } + + + + + + + + + + + // const subjectThreshold = + + + // Math.max(config.get('inputValidationLength') || 50, config.get('subjectValidationLength') || 50, 0) || 50; + + if (line.length <= threshold) { if (setting !== 'always') { return; } return { - message: localize('commitMessageCountdown', "{0} characters left in current line", subjectThreshold - 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 - subjectThreshold, subjectThreshold), + message: localize('commitMessageWarning', "{0} characters over {1} in current line", line.length - threshold, threshold), type: SourceControlInputBoxValidationType.Warning }; }