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

When moving to next or prev workspace, don't skip colliding number #4451

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

Conversation

jolmg
Copy link

@jolmg jolmg commented Jun 28, 2021

This fixes an issue where, having workspaces: 1, 2:foo, 2:bar, and 3,
moving from 2:foo to next moves us to workspace 3, and moving from 2:bar
to prev moves us to workspace 1.

With this change, moving from 2:foo to next would move us to 2:bar, and
from 2:bar to prev would move us to 2:foo.

Closes #4452

This fixes an issue where, having workspaces: 1, 2:foo, 2:bar, and 3,
moving from 2:foo to next moves us to workspace 3, and moving from 2:bar
to prev moves us to workspace 1.

With this change, moving from 2:foo to next would move us to 2:bar, and
from 2:bar to prev would move us to 2:foo.
@jolmg
Copy link
Author

jolmg commented Jun 28, 2021

Closes #4452

@orestisfl orestisfl self-requested a review June 28, 2021 12:54
@jolmg
Copy link
Author

jolmg commented Jun 28, 2021

I just noticed that besides workspace_{next,prev}(), there are also workspace_{next,prev}_on_output(). Those would also need the same change.

@jolmg
Copy link
Author

jolmg commented Jun 29, 2021

Change has been extended to {next,prev}_on_output.

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.

Thanks!

Made some nit picks which I think mildly simplify things, otherwise LGTM

src/workspace.c Outdated
Comment on lines 720 to 721
next = child;
goto workspace_next_on_output_end;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
next = child;
goto workspace_next_on_output_end;
return child;

Copy link
Author

@jolmg jolmg Sep 20, 2021

Choose a reason for hiding this comment

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

Ditto, 19 lines below. This function follows a single-return style. It seems the previous ones were also originally written in such a style.

Personally, I find the assignment clearer. It allows one to visually scan the function source for next = in order to determine where next is determined. With this change, one would have to pay a bit more attention that return child also determines what the next is. It breaks the overall consistency.

Copy link
Author

Choose a reason for hiding this comment

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

Done. 12bd3f8

src/workspace.c Outdated
Comment on lines 679 to 680
prev = child;
return prev;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
prev = child;
return prev;
return child;

Copy link
Author

Choose a reason for hiding this comment

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

Ditto, 24 lines above.

Copy link
Author

Choose a reason for hiding this comment

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

Done. 12bd3f8

src/workspace.c Outdated
Comment on lines 607 to 608
next = child;
return next;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
next = child;
return next;
return child;

Copy link
Author

Choose a reason for hiding this comment

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

This was to be consistent with the style used 23 lines above. Should I change that as well?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please change them. Early returns are preferable.

Copy link
Author

Choose a reason for hiding this comment

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

Done. 12bd3f8

src/workspace.c Outdated
Comment on lines 782 to 783
prev = child;
goto workspace_prev_on_output_end;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
prev = child;
goto workspace_prev_on_output_end;
return child;

Copy link
Author

Choose a reason for hiding this comment

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

Ditto, 20 lines below.

Copy link
Author

Choose a reason for hiding this comment

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

Done. 12bd3f8

@orestisfl
Copy link
Member

Also, the release notes need to be updated: https://github.com/i3/i3/blob/next/RELEASE-NOTES-next

jolmg and others added 2 commits September 20, 2021 11:59
Co-authored-by: Orestis Floros <orestisflo@gmail.com>
@jolmg
Copy link
Author

jolmg commented Sep 20, 2021

I've updated the release notes.

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.

No skipping number-colliding workspaces with workspace next/prev
3 participants