mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
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 <cursoragent@cursor.com>
This commit is contained in:
parent
8619c07f3f
commit
794e0e0c37
1 changed files with 10 additions and 5 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue