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: zellij attach when the -c / --create option is passed #2264

Closed
wants to merge 1 commit into from
Closed

fix: zellij attach when the -c / --create option is passed #2264

wants to merge 1 commit into from

Conversation

dsully
Copy link

@dsully dsully commented Mar 10, 2023

assert_session_ne is called before the value of -c is known to create a session when attaching if it doesn't exist.

Move the call (and duplicate) to perform the session name validation, passing a boolean along to denote creation.

Comment on lines -336 to -339
let start_client_plan = |session_name: std::string::String| {
assert_session_ne(&session_name);
};

Choose a reason for hiding this comment

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

I am not a maintainer but it seems that the start_client_plan is an arrow function definition. It is not actually called here. It is just defined in this scope to avoid needing to define it more than once. So I don't think this is a needed change

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure I understand. This is the only place that assert_session_ne is called.

Choose a reason for hiding this comment

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

I know the issue was closed but it might be helpful for an explanation on what I mean. so the function assert_session_ne is called inside the following function. I was also using the wrong term for what they are considered in rust, arrow function is from javascript but rust they are closures you can check this article out
https://www.educative.io/answers/what-are-closures-in-rust

let start_client_plan = |session_name: std::string::String| {
    assert_session_ne(&session_name);
};

but the start_client_plan is just a variable that holds the closure that will call the assert_session_plan

`|session_name: std::string::String| assert_session_ne(&session_name);`

so this assert_session_ne is actually called here in the map function that will apply the function to the session name.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, “arrow function” threw me off. I’m very familiar with closures in other languages. 😎

@imsnif
Copy link
Member

imsnif commented Mar 10, 2023

I really appreciate your efforts, but... #2247

@imsnif imsnif closed this Mar 10, 2023
@dsully
Copy link
Author

dsully commented Mar 10, 2023

Great, I searched but didn't find that one.

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.

None yet

3 participants