Skip to content

Commit

Permalink
Fix bug with command indexes and hints
Browse files Browse the repository at this point in the history
  • Loading branch information
doonv committed Dec 29, 2023
1 parent b663a8f commit d1eadc3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,18 @@ pub(crate) fn render_ui(
.auto_shrink([false, true])
.show(ui, |ui| {
ui.vertical(|ui| {
let mut command_index = 0;

for (id, (message, is_new)) in state.log.iter_mut().enumerate() {
add_log(ui, id, message, is_new, &mut hints, &config);
add_log(
ui,
id,
message,
is_new,
&mut hints,
&config,
&mut command_index,
);
}
});
});
Expand All @@ -130,14 +140,13 @@ fn add_log(
is_new: &mut bool,
hints: &mut CommandHints,
config: &ConsoleConfig,
command_index: &mut usize,
) {
let mut command_index = 0;

ui.push_id(id, |ui| {
let time_utc = system_time_to_chrono_utc(event.time);
let time: DateTime<chrono::Local> = time_utc.into();

let text = format_line(time, config, event, *is_new, &mut command_index, hints);
let text = format_line(time, config, event, *is_new, command_index, hints);
let label = ui.label(text);

if *is_new {
Expand Down Expand Up @@ -206,6 +215,8 @@ fn format_line(
}
let hints = &hints[*command_index];

dbg!(&command_index);

// TODO: Handle more than just he first element
if let Some(hint) = hints.first() {
const PREFIX_LEN: usize = COMMAND_MESSAGE_PREFIX.len();
Expand Down

0 comments on commit d1eadc3

Please sign in to comment.