mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 00:03:13 +03:00
fix(cli-rs): number a dialog field's ctrl+c clear as an edit
fields-fix numbers each change of a field, and a view's echo names the number it saw. The ctrl+c clear of a dialog surface's field reported its change without one, so it no longer built. It now takes the next number and records it with the field's other edits.
This commit is contained in:
@@ -653,8 +653,8 @@ impl Tree {
|
||||
}
|
||||
|
||||
/// Empties the tree's input that has the focus, if it shows text, as an edit of the user's would: the id of the
|
||||
/// input, whose handler is to hear the change.
|
||||
pub(crate) fn clear_focused_field(&self, app: &App) -> Option<String> {
|
||||
/// input and the edit's number, which its handler is to hear.
|
||||
pub(crate) fn clear_focused_field(&self, app: &App) -> Option<(String, u64)> {
|
||||
let focused = app.focused()?.id();
|
||||
let mut cleared = None;
|
||||
each(&self.nodes, &mut |node| {
|
||||
@@ -663,12 +663,13 @@ impl Tree {
|
||||
&& !field.draft().0.is_empty()
|
||||
{
|
||||
field.set("");
|
||||
let seq = EDITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed) + 1;
|
||||
let mut reported = reported.borrow_mut();
|
||||
if reported.len() == ECHOES {
|
||||
reported.remove(0);
|
||||
reported.pop_front();
|
||||
}
|
||||
reported.push(String::new());
|
||||
cleared = Some(id.to_owned());
|
||||
reported.push_back((seq, String::new()));
|
||||
cleared = Some((id.to_owned(), seq));
|
||||
}
|
||||
});
|
||||
cleared
|
||||
|
||||
@@ -1433,9 +1433,9 @@ impl Claimed for Rc<Surface> {
|
||||
}
|
||||
|
||||
fn clear_field(&self, host: &dyn Host) -> bool {
|
||||
let Some(node) = self.state.borrow().tree.clear_focused_field(host.app()) else { return false };
|
||||
let Some((node, seq)) = self.state.borrow().tree.clear_focused_field(host.app()) else { return false };
|
||||
if let Some(owner) = self.holder() {
|
||||
owner.hear(&abi::interact::Event::Change { node, text: String::new() });
|
||||
owner.hear(&abi::interact::Event::Change { node, text: String::new(), seq });
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
@@ -1695,8 +1695,8 @@ fn dialog_probe(setup: &mut abi::Setup) -> Result<(), String> {
|
||||
}));
|
||||
let record = |_: &dyn abi::Host, event: &abi::interact::Event| {
|
||||
let line = match event {
|
||||
abi::interact::Event::Change { node, text } if node == "name" => format!("change {text}"),
|
||||
abi::interact::Event::Change { node, text } => format!("change {node} {text}"),
|
||||
abi::interact::Event::Change { node, text, .. } if node == "name" => format!("change {text}"),
|
||||
abi::interact::Event::Change { node, text, .. } => format!("change {node} {text}"),
|
||||
abi::interact::Event::Closed { surface } => format!("closed {surface}"),
|
||||
// Big-boi's ds-7: a bind of escape that would take it.
|
||||
abi::interact::Event::Key(key) if key.bind.as_deref() == Some("esc") => {
|
||||
|
||||
Reference in New Issue
Block a user