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

restore cursor shape when exits #9314

Merged
merged 1 commit into from May 30, 2023
Merged

restore cursor shape when exits #9314

merged 1 commit into from May 30, 2023

Conversation

nibon7
Copy link
Contributor

@nibon7 nibon7 commented May 29, 2023

Description

This PR restores cursor shape when nushell exists.

Fixes #9243

Related nushell/reedline#574

User-Facing Changes

  • windows
windows_ps.mp4
  • linux
linux_alacritty.mp4
  • macos
mac_iterm2.mp4

Tests + Formatting

After Submitting

@fdncred
Copy link
Collaborator

fdncred commented May 29, 2023

Seems reasonable. I'm guessing from the code that the drop(line_editor) is what is resetting the cursor? What happens on panic? What happens with parameters like -c?

@nibon7
Copy link
Contributor Author

nibon7 commented May 30, 2023

I'm guessing from the code that the drop(line_editor) is what is resetting the cursor?

Yeah, when the reedline object is destructed, cursor shape will be reset.

What happens on panic?

When a panic occurs, stack unwinding is triggered. During the stack unwinding process, the destructor functions of objects that implement the Drop trait will be called.

If the reedline object still exists on the stack when a panic occurs, the destructor will be executed and the cursor shape will be reset.
Screenshot from 2023-05-30 08-57-49

If you set "panic=abort" in Cargo.toml, when a panic occurs, nushell will immediately abort rather than perform any further cleanup, and the cursor shape will not be reset.

Screenshot from 2023-05-30 10-31-42

What happens with parameters like -c?

This change has nothing to do with it as nu -c invokes evaluate_commands which doesn't create a Reedline instance and the cursor never changed.

PS: nu /path/to/script.nu doesn't create a Reedline instance too.

@fdncred
Copy link
Collaborator

fdncred commented May 30, 2023

Ok, thanks for the hard work and research @nibon7. Let's give this a try.

@fdncred fdncred merged commit 560c2e6 into nushell:main May 30, 2023
16 checks passed
@nibon7 nibon7 deleted the cursor_shape branch May 31, 2023 00:05
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.

Cursor style is changed after exit
2 participants