fix(records): allow adding rows in empty records view
Add helper methods to CmdContext to clarify layout state and synthetic record presence. Update AddRecordRow to check for records mode generally rather than requiring a synthetic record at the current cursor, which allows adding the first row to an empty records view. Includes a regression test for the empty records view scenario. Co-Authored-By: fiddlerwoaroof/git-smart-commit (gemma-4-31B-it-UD-Q4_K_XL.gguf)
This commit is contained in:
@ -48,9 +48,22 @@ pub struct CmdContext<'a> {
|
||||
}
|
||||
|
||||
impl<'a> CmdContext<'a> {
|
||||
/// Return true when the current layout is a records-mode layout.
|
||||
pub fn is_records_mode(&self) -> bool {
|
||||
self.layout.is_records_mode()
|
||||
}
|
||||
|
||||
pub fn cell_key(&self) -> Option<CellKey> {
|
||||
self.layout.cell_key(self.selected.0, self.selected.1)
|
||||
}
|
||||
|
||||
/// Return synthetic record coordinates for the current cursor, if any.
|
||||
pub fn synthetic_record_at_cursor(&self) -> Option<(usize, String)> {
|
||||
self.cell_key()
|
||||
.as_ref()
|
||||
.and_then(crate::view::synthetic_record_info)
|
||||
}
|
||||
|
||||
pub fn row_count(&self) -> usize {
|
||||
self.layout.row_count()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user