Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mark restoration #6221

Open
wants to merge 3 commits into
base: next
Choose a base branch
from
Open

Fix mark restoration #6221

wants to merge 3 commits into from

Conversation

yurikhan
Copy link

@yurikhan yurikhan commented Sep 1, 2024

Closes #4334.

@yurikhan yurikhan marked this pull request as draft September 1, 2024 07:00
@yurikhan yurikhan force-pushed the fix-mark-restoration branch 2 times, most recently from b29ef60 to baa16f2 Compare September 1, 2024 08:11
Copy link
Member

@orestisfl orestisfl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Besides my nitpick, could you please also include some new tests?

Comment on lines 55 to 67
static void apply_pending_marks(void) {
if (num_marks > 0) {
LOG("applying %d pending marks\n", num_marks);
for (int i = 0; i < num_marks; i ) {
Con *con = marks[i].con_to_be_marked;
char *mark = marks[i].mark;
if (con) {
DLOG("applying pending mark “%s” to con %p\n", mark, con);
con_mark(con, mark, MM_ADD);
}
free(mark);
}

FREE(marks);
num_marks = 0;
LOG("done applying pending marks\n");
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for LOG()-level messages, con_mark also prints a log message.

Suggested change
static void apply_pending_marks(void) {
if (num_marks > 0) {
LOG("applying %d pending marks\n", num_marks);
for (int i = 0; i < num_marks; i ) {
Con *con = marks[i].con_to_be_marked;
char *mark = marks[i].mark;
if (con) {
DLOG("applying pending mark “%s” to con %p\n", mark, con);
con_mark(con, mark, MM_ADD);
}
free(mark);
}
FREE(marks);
num_marks = 0;
LOG("done applying pending marks\n");
}
}
static void apply_pending_marks(void) {
for (int i = 0; i < num_marks; i ) {
Con *con = marks[i].con_to_be_marked;
char *mark = marks[i].mark;
if (con) {
con_mark(con, mark, MM_ADD);
}
free(mark);
}
FREE(marks);
num_marks = 0;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* json_key: Do not lose existing pending marks
* json_end_map: Do not apply pending marks prematurely
* apply_pending_marks, tree_append_json: Skip setting marks on
  incomplete containers
* tree_append_json: Apply pending marks after finishing JSON parsing
@yurikhan
Copy link
Author

Thank you. Besides my nitpick, could you please also include some new tests?

Added test.

I’m not well versed in Perl; when I tried to cargo-cult the is_deeply(sort(get_marks()), …) check, I found it did not reliably sort. I had to dereference the return value of get_marks() before sorting and turn the resulting list back into a reference to get is_deeply to stop complaining about argument count.

Existing tests using the same check pass for me. What am I missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

append_layout does not apply marks to parent container if child container also has mark
2 participants