Skip to content

Commit

Permalink
sheet: Use buffer status on first display to prevent race in testing
Browse files Browse the repository at this point in the history
Allows us to wait for indexing to finish during testing without
needing to sleep to avoid matching the initial status.
  • Loading branch information
richiejp committed Dec 9, 2024
1 parent 0dfeed6 commit 190868c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/sheet.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *op
cbreak();
set_escdelay(30);
struct zsvsheet_display_dimensions display_dims = get_display_dimensions(1, 1);
if (current_ui_buffer->status)
zsvsheet_priv_set_status(&display_dims, 1, current_ui_buffer->status);
display_buffer_subtable(current_ui_buffer, header_span, &display_dims);

zsvsheet_register_builtin_procedures();
Expand Down
7 changes: 1 addition & 6 deletions app/sheet/read-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,7 @@ static void *get_data_index(void *gdi) {
pthread_mutex_unlock(&uib->mutex);

char *ui_status;
/* I think there was a race between this print and a "? for help" which causes
* ci to fail. Once read-file is called the main thread displays its contents
* and this thread indexes the file. There is no synchronisation between the
* two so the status we end up with is random.
*/
// asprintf(&ui_status, "%s(building index) ", old_ui_status ? old_ui_status : "");
asprintf(&ui_status, "%s(building index) ", old_ui_status ? old_ui_status : "");

pthread_mutex_lock(&uib->mutex);
uib->status = ui_status;
Expand Down

0 comments on commit 190868c

Please sign in to comment.