Merge pull request 'tui: yolo while a prompt is running' (#170) from feat/yolo-while-busy into main
This commit was merged in pull request #170.
This commit is contained in:
commit
28c3d79286
3 files changed
+18
-2
No files matched your search
@@ -366,6 +366,10 @@ impl Allow {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn yolo_on(&self) -> bool {
|
||||
self.yolo
|
||||
}
|
||||
|
||||
/// Toggle: allow everything (not persisted); returns the new state.
|
||||
pub fn toggle_yolo(&mut self) -> bool {
|
||||
self.yolo = !self.yolo;
|
||||
|
||||
@@ -453,6 +453,18 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
|
||||
dirty = true;
|
||||
match ev {
|
||||
TEvent::Key(k) if k.kind != KeyEventKind::Release && app.perm.is_some() => {
|
||||
if k.code == KeyCode::Char('!') {
|
||||
let mut a = app.state.allow.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if !a.yolo_on() {
|
||||
a.toggle_yolo();
|
||||
}
|
||||
drop(a);
|
||||
if let Some((p, reply)) = app.perm.take() {
|
||||
app.t.push(Item::Info(format!("yolo on; allowed {} {}", p.req.tool, p.req.detail)));
|
||||
let _ = reply.send(hx_core::permit::Decision::Once);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if let Some((p, _)) = &mut app.perm
|
||||
&& let Some(d) = p.key(k)
|
||||
&& let Some((p, reply)) = app.perm.take()
|
||||
@@ -1272,7 +1284,7 @@ async fn submit(app: &mut App, mut line: String, c: &Ctx<'_>) {
|
||||
let (c, arg) = cmd
|
||||
.split_once(' ')
|
||||
.map_or((cmd, ""), |(a, b)| (a, b.trim()));
|
||||
if app.busy && !matches!(c, "quit" | "btw") {
|
||||
if app.busy && !matches!(c, "quit" | "btw" | "yolo") {
|
||||
app.t.push(Item::Error("busy; esc to abort first".into()));
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user