From 794e0e0c373f1a3135d4e8cc63d82fd6e6e28d61 Mon Sep 17 00:00:00 2001 From: wuyangfan <1102042793@qq.com> Date: Sun, 17 May 2026 17:57:20 +0800 Subject: [PATCH] feat(commit): warn at 50 chars, error at 72 for subject line (#1635) Show a yellow subject-length hint after 50 characters and switch to the existing red style once the summary exceeds 72 characters. Co-authored-by: Cursor --- src/popups/commit.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/popups/commit.rs b/src/popups/commit.rs index b5dff7677c..d0220122c9 100644 --- a/src/popups/commit.rs +++ b/src/popups/commit.rs @@ -8,7 +8,7 @@ use crate::{ options::SharedOptions, queue::{InternalEvent, NeedsUpdate, Queue}, strings, try_or_popup, - ui::style::SharedTheme, + ui::style::{SharedTheme, Theme}, }; use anyhow::{bail, Ok, Result}; use asyncgit::sync::commit::commit_message_prettify; @@ -65,7 +65,8 @@ pub struct CommitPopup { verify: bool, } -const FIRST_LINE_LIMIT: usize = 50; +const FIRST_LINE_WARN: usize = 50; +const FIRST_LINE_ERROR: usize = 72; impl CommitPopup { /// @@ -122,11 +123,15 @@ impl CommitPopup { .map(str::len) .unwrap_or_default(); - if first_line > FIRST_LINE_LIMIT { + if first_line > FIRST_LINE_WARN { let msg = strings::commit_first_line_warning(first_line); let msg_length: u16 = msg.len().cast(); - let w = - Paragraph::new(msg).style(self.theme.text_danger()); + let style = if first_line > FIRST_LINE_ERROR { + self.theme.text_danger() + } else { + Theme::attention_block() + }; + let w = Paragraph::new(msg).style(style); let rect = { let mut rect = self.input.get_area();