Skip to content

Commit 8b85492

Browse files
committed
fix(tui): move config cursor to newly added entry after flush
Signed-off-by: Artem Lytvyn <[email protected]>
1 parent 91894db commit 8b85492

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

  • crates/openshell-tui/src

‎crates/openshell-tui/src/app.rs‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,7 @@ impl App {
22922292
form.key_field = ProviderKeyField::ConfigKeyName;
22932293
} else {
22942294
form.key_field = ProviderKeyField::ConfigList;
2295+
form.config_cursor = 0_usize;
22952296
}
22962297
}
22972298
ProviderKeyField::ConfigList => {
@@ -2307,6 +2308,7 @@ impl App {
23072308
&mut form.config_value_input,
23082309
) {
23092310
form.key_field = ProviderKeyField::ConfigKeyName;
2311+
form.config_cursor = form.config.len().saturating_sub(1_usize);
23102312
} else if form.config_key_input.is_empty()
23112313
&& form.config_value_input.is_empty()
23122314
{
@@ -2332,17 +2334,19 @@ impl App {
23322334
form.key_field = ProviderKeyField::ConfigKeyName;
23332335
} else {
23342336
form.key_field = ProviderKeyField::ConfigList;
2337+
form.config_cursor = 0_usize;
23352338
}
23362339
} else {
23372340
form.key_field = ProviderKeyField::Credential;
2338-
form.cred_cursor = 0;
2341+
form.cred_cursor = 0_usize;
23392342
}
23402343
}
23412344
ProviderKeyField::Credential => {
23422345
if form.cred_cursor < form.credentials.len().saturating_sub(1) {
23432346
form.cred_cursor += 1;
23442347
} else if !form.config.is_empty() {
23452348
form.key_field = ProviderKeyField::ConfigList;
2349+
form.config_cursor = 0_usize;
23462350
} else {
23472351
form.key_field = ProviderKeyField::ConfigKeyName;
23482352
}
@@ -2360,6 +2364,7 @@ impl App {
23602364
&mut form.config_value_input,
23612365
) {
23622366
form.key_field = ProviderKeyField::ConfigKeyName;
2367+
form.config_cursor = form.config.len().saturating_sub(1_usize);
23632368
} else if form.config_key_input.is_empty()
23642369
&& form.config_value_input.is_empty()
23652370
{
@@ -2488,6 +2493,7 @@ impl App {
24882493
&mut form.config_value_input,
24892494
) {
24902495
form.key_field = ProviderKeyField::ConfigKeyName;
2496+
form.config_cursor = form.config.len().saturating_sub(1_usize);
24912497
}
24922498
}
24932499
_ => {
@@ -2683,6 +2689,7 @@ impl App {
26832689
form.focus = UpdateProviderField::ConfigKey;
26842690
} else {
26852691
form.focus = UpdateProviderField::ConfigEntry;
2692+
form.config_cursor = 0_usize;
26862693
}
26872694
}
26882695
UpdateProviderField::ConfigEntry => {
@@ -2698,6 +2705,7 @@ impl App {
26982705
&mut form.config_value_input,
26992706
) {
27002707
form.focus = UpdateProviderField::ConfigKey;
2708+
form.config_cursor = form.config.len().saturating_sub(1_usize);
27012709
} else if form.config_key_input.is_empty() && form.config_value_input.is_empty()
27022710
{
27032711
form.focus = UpdateProviderField::Submit;
@@ -2783,6 +2791,7 @@ impl App {
27832791
&mut form.config_value_input,
27842792
) {
27852793
form.focus = UpdateProviderField::ConfigKey;
2794+
form.config_cursor = form.config.len().saturating_sub(1_usize);
27862795
}
27872796
}
27882797
_ => {
@@ -2803,10 +2812,7 @@ impl App {
28032812
);
28042813
return;
28052814
}
2806-
if form.new_value.is_empty()
2807-
&& form.config.is_empty()
2808-
&& form.deleted_keys.is_empty()
2809-
{
2815+
if form.new_value.is_empty() && form.config == form.original_config {
28102816
form.status =
28112817
Some("Credential value or config keys required.".to_string());
28122818
return;

0 commit comments

Comments
 (0)