refactor: update commit commands to continue editing after advance
Update commit commands to continue editing after advancing cursor. CommitCellEdit now advances cursor (typewriter-style) and re-enters edit mode at the new cell, allowing continuous data entry. CommitCategoryAdd and CommitItemAdd now exit to CategoryPanel when the buffer is empty, instead of just clearing the buffer. Empty buffer behavior: - CommitCategoryAdd: empty → exit to CategoryPanel - CommitItemAdd: empty → exit to CategoryPanel - Non-empty: add item/category, clear buffer, stay in add mode Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
@ -1318,9 +1318,8 @@ impl Cmd for CycleAxisAtCursor {
|
|||||||
"cycle-axis-at-cursor"
|
"cycle-axis-at-cursor"
|
||||||
}
|
}
|
||||||
fn execute(&self, ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
|
fn execute(&self, ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
|
||||||
let cat_names = ctx.model.category_names();
|
if let Some(cat_name) = ctx.cat_at_cursor() {
|
||||||
if let Some(cat_name) = cat_names.get(ctx.cat_panel_cursor) {
|
vec![Box::new(effect::CycleAxis(cat_name))]
|
||||||
vec![Box::new(effect::CycleAxis(cat_name.to_string()))]
|
|
||||||
} else {
|
} else {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
@ -1335,10 +1334,9 @@ impl Cmd for OpenItemAddAtCursor {
|
|||||||
"open-item-add-at-cursor"
|
"open-item-add-at-cursor"
|
||||||
}
|
}
|
||||||
fn execute(&self, ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
|
fn execute(&self, ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
|
||||||
let cat_names = ctx.model.category_names();
|
if let Some(cat_name) = ctx.cat_at_cursor() {
|
||||||
if let Some(cat_name) = cat_names.get(ctx.cat_panel_cursor) {
|
|
||||||
vec![effect::change_mode(AppMode::ItemAdd {
|
vec![effect::change_mode(AppMode::ItemAdd {
|
||||||
category: cat_name.to_string(),
|
category: cat_name,
|
||||||
buffer: String::new(),
|
buffer: String::new(),
|
||||||
})]
|
})]
|
||||||
} else {
|
} else {
|
||||||
@ -1962,12 +1960,13 @@ impl Cmd for CommitCellEdit {
|
|||||||
)));
|
)));
|
||||||
effects.push(effect::mark_dirty());
|
effects.push(effect::mark_dirty());
|
||||||
}
|
}
|
||||||
effects.push(effect::change_mode(AppMode::Normal));
|
// Advance cursor down (typewriter-style) and re-enter edit mode
|
||||||
// Advance cursor down (typewriter-style)
|
// at the new cell so the user can continue data entry.
|
||||||
let adv = EnterAdvance {
|
let adv = EnterAdvance {
|
||||||
cursor: CursorState::from_ctx(ctx),
|
cursor: CursorState::from_ctx(ctx),
|
||||||
};
|
};
|
||||||
effects.extend(adv.execute(ctx));
|
effects.extend(adv.execute(ctx));
|
||||||
|
effects.push(Box::new(effect::EnterEditAtCursor));
|
||||||
effects
|
effects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2013,18 +2012,19 @@ impl Cmd for CommitCategoryAdd {
|
|||||||
fn execute(&self, ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
|
fn execute(&self, ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
|
||||||
let buf = ctx.buffers.get("category").cloned().unwrap_or_default();
|
let buf = ctx.buffers.get("category").cloned().unwrap_or_default();
|
||||||
let trimmed = buf.trim().to_string();
|
let trimmed = buf.trim().to_string();
|
||||||
let mut effects: Vec<Box<dyn Effect>> = Vec::new();
|
if trimmed.is_empty() {
|
||||||
if !trimmed.is_empty() {
|
// Empty → exit category-add mode
|
||||||
effects.push(Box::new(effect::AddCategory(trimmed.clone())));
|
return vec![effect::change_mode(AppMode::CategoryPanel)];
|
||||||
effects.push(effect::mark_dirty());
|
|
||||||
effects.push(effect::set_status(format!("Added category \"{trimmed}\"")));
|
|
||||||
}
|
}
|
||||||
// Clear buffer for next entry
|
vec![
|
||||||
effects.push(Box::new(effect::SetBuffer {
|
Box::new(effect::AddCategory(trimmed.clone())),
|
||||||
name: "category".to_string(),
|
effect::mark_dirty(),
|
||||||
value: String::new(),
|
effect::set_status(format!("Added category \"{trimmed}\"")),
|
||||||
}));
|
Box::new(effect::SetBuffer {
|
||||||
effects
|
name: "category".to_string(),
|
||||||
|
value: String::new(),
|
||||||
|
}),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2038,27 +2038,27 @@ impl Cmd for CommitItemAdd {
|
|||||||
fn execute(&self, ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
|
fn execute(&self, ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
|
||||||
let buf = ctx.buffers.get("item").cloned().unwrap_or_default();
|
let buf = ctx.buffers.get("item").cloned().unwrap_or_default();
|
||||||
let trimmed = buf.trim().to_string();
|
let trimmed = buf.trim().to_string();
|
||||||
// Get the category from the mode
|
if trimmed.is_empty() {
|
||||||
|
// Empty → exit item-add mode
|
||||||
|
return vec![effect::change_mode(AppMode::CategoryPanel)];
|
||||||
|
}
|
||||||
let category = if let AppMode::ItemAdd { category, .. } = ctx.mode {
|
let category = if let AppMode::ItemAdd { category, .. } = ctx.mode {
|
||||||
category.clone()
|
category.clone()
|
||||||
} else {
|
} else {
|
||||||
return vec![];
|
return vec![];
|
||||||
};
|
};
|
||||||
let mut effects: Vec<Box<dyn Effect>> = Vec::new();
|
vec![
|
||||||
if !trimmed.is_empty() {
|
Box::new(effect::AddItem {
|
||||||
effects.push(Box::new(effect::AddItem {
|
|
||||||
category,
|
category,
|
||||||
item: trimmed.clone(),
|
item: trimmed.clone(),
|
||||||
}));
|
}),
|
||||||
effects.push(effect::mark_dirty());
|
effect::mark_dirty(),
|
||||||
effects.push(effect::set_status(format!("Added \"{trimmed}\"")));
|
effect::set_status(format!("Added \"{trimmed}\"")),
|
||||||
}
|
Box::new(effect::SetBuffer {
|
||||||
// Clear buffer for next entry
|
name: "item".to_string(),
|
||||||
effects.push(Box::new(effect::SetBuffer {
|
value: String::new(),
|
||||||
name: "item".to_string(),
|
}),
|
||||||
value: String::new(),
|
]
|
||||||
}));
|
|
||||||
effects
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user