Show Line Length Indicator at 72 Characters for Commit Messages
This is recommended line length for commit messages.
Screenshot: https://imgur.com/a/Mi8dOLR
Google-Bug-Id: b/361035569
Release-Notes: skip
Change-Id: Iadaac002ad7be33f69bac2fe5e051ff501e964bf
diff --git a/web/element/codemirror-element.ts b/web/element/codemirror-element.ts
index 98dd811..206d7fd 100644
--- a/web/element/codemirror-element.ts
+++ b/web/element/codemirror-element.ts
@@ -113,13 +113,17 @@
this.darkMode
),
EditorView.updateListener.of(update => {
- if (this.prefs?.line_length) {
+ // Set ruler width to 72 for commit messages,
+ // as this is the recommended line length for git commit messages.
+ if (this.fileType?.includes('x-gerrit-commit-message')) {
+ updateRulerWidth(72, update.view.defaultCharacterWidth, true);
+ } else if (this.prefs?.line_length) {
// This is required to be in the setTimeout() to ensure the
// line is set as correctly as possible.
updateRulerWidth(
- this.prefs.line_length,
- update.view.defaultCharacterWidth,
- true
+ this.prefs.line_length,
+ update.view.defaultCharacterWidth,
+ true
);
}