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

Ability to cycle through tags #282

Closed
wants to merge 2 commits into from
Closed

Conversation

griccardos
Copy link

@griccardos griccardos commented Oct 14, 2023

implements issue #280
Adds two functions next_tag and previous_tag which can be called to cycle through tags
let me know if you need me to make any changes

@sminez
Copy link
Owner

sminez commented Oct 14, 2023

Can you add unit test for the new functionality please? There should be plenty of examples of existing tests to base them on in the that file

@griccardos
Copy link
Author

Have added a test for cycling forward, backwards and wrapping around

self.focus_tag(new_tag);
}

///Move focus to previous tag
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add a leading space to doc comments please and also add a quick explanation about the semantics of next/previous tag given that it might not be immediately obvious to users as this ordering is derived from workspace ID (so effectively creation order) rather than numeric or alphabetical order.

@@ -1277,6 +1309,26 @@ pub mod tests {

assert!(matches!(res, Err(Error::NoScreens)));
}


#[test_case(true,1,1; "forward")]
Copy link
Owner

Choose a reason for hiding this comment

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

Clippy probably wont pick up on this but can you add spaces between the macro arguments here please?

@sminez
Copy link
Owner

sminez commented Oct 14, 2023

@griccardos can you please rebase to develop and run rustfmt and clippy locally to address the issues that are being raised in the PR checks? Once that's done and the two changes I've requested are handled I think this looks like it should be good to merge 👍

@griccardos
Copy link
Author

I have done the changes as requested. Sorry, i forgot to do the fmt, because i was using helix editor. But it seems to be happy now. Let me know if i did the rebase correctly, its not something I do very often...

@sminez
Copy link
Owner

sminez commented Oct 17, 2023

Looking at this again, I'm not sure about the use of unwrap_or_default if I'm honest. The current tag must be present in ordered_tags: if not then something has gone seriously wrong, and defaulting to the first tag in that instance feels like a) odd behaviour to provide in that case and b) masking a much bigger issue.

Can you replace both instances of unwrap_or_default with an expect please? The message should be something along the lines of "current tag is a known tag".

I'm not super happy about this sort of state manipulation being outside of the pure data structures really (they handle these sorts of invariants so API quirks like position returning an option that has to be Some aren't an issue). That said, I can't think of a way to do it differently and this is likely why I didn't provide these methods in the first place. The other state manipulation methods (mostly on a Stack) all have quickcheck tests to ensure that they behave correctly for arbitrary inputs and initial states. Doing that for these two new methods should be possible but is likely going to involve a bit of set-up to get it working smoothly I suspect.

@griccardos
Copy link
Author

griccardos commented Oct 19, 2023 via email

@sminez
Copy link
Owner

sminez commented Apr 14, 2024

Closing as there has been no further activity on this and the previous discussion highlights several issues with how this fits within the existing API.

@sminez sminez closed this Apr 14, 2024
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.

2 participants