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

Make cursor_shape optional #10289

Merged
merged 3 commits into from Sep 9, 2023
Merged

Make cursor_shape optional #10289

merged 3 commits into from Sep 9, 2023

Conversation

nibon7
Copy link
Contributor

@nibon7 nibon7 commented Sep 9, 2023

Description

There are several cursor shape related issues #7151 #9243 #7271 #8452 #10169, you can't disable the cursor shape feature even if you comment out the entire cursor_shape block in the config.nu, and even worse, when nushell exits with an error, the cursor shape can't be restored, that is annoying.

This PR provides an opportunity to disable setting the cursor shape.

User-Facing Changes

If you use the default config.nu, nothing changes, but if you comment out cursor_shape block or set them to inherit, related cursor shape will not be set.

Tests + Formatting

After Submitting

@fdncred
Copy link
Collaborator

fdncred commented Sep 9, 2023

Thanks @nibon7. I'd love to see this work, because you're right, we've had a few complaints about it recently.

It kind of sounds like, if cursor shape is commented it, it "inherts" whatever cursor shape you already have. Is that right? If so, I'm wondering if inherit should be an option too and it just sets the cursor to None?

@nibon7
Copy link
Contributor Author

nibon7 commented Sep 9, 2023

If the cursor_shape block is commented out, the line editor will not set the cursor shape.

see https://github.com/nushell/reedline/blob/409b51784f108d7e1f004dfa2dc11d727c95b6f7/src/painting/painter.rs#L181-L191

@nibon7
Copy link
Contributor Author

nibon7 commented Sep 9, 2023

Should we provide an option just like none or something else to skip setting the cursor shape?

cursor_shape: {
    emacs: none
    vi_insert: none
    vi_normal: none
}

@fdncred
Copy link
Collaborator

fdncred commented Sep 9, 2023

Should we provide an option just like none or something else to skip setting the cursor shape?

That is what I was asking. I originally was going to suggest "none" but then I thought people would think that would mean no cursor would appear, and therefore be confusing, which is why I suggested "inherit". However, if "inhert" is not really what it's doing and doesn't describe it well enough, I'm up for other terminology.

@nibon7
Copy link
Contributor Author

nibon7 commented Sep 9, 2023

I originally was going to suggest "none" but then I thought people would think that would mean no cursor would appear, and therefore be confusing, which is why I suggested "inherit".

You're absolutely right.

@fdncred
Copy link
Collaborator

fdncred commented Sep 9, 2023

Thanks @nibon7! Just to be clear, if we set each cursor_shape to inherit, that produces the same behavior as commenting out the entire cursor_shape record. Is that correct?

@nibon7
Copy link
Contributor Author

nibon7 commented Sep 9, 2023

Just to be clear, if we set each cursor_shape to inherit, that produces the same behavior as commenting out the entire cursor_shape record. Is that correct?

Yes. If we comment out the cursor_shape record, it will use the default values None, same as inherit.

@@ -156,9 +156,9 @@ impl Default for Config {
             filesize_metric: false,
             filesize_format: "auto".into(),

-            cursor_shape_emacs: NuCursorShape::Line,
-            cursor_shape_vi_insert: NuCursorShape::Block,
-            cursor_shape_vi_normal: NuCursorShape::UnderScore,
+            cursor_shape_emacs: None,
+            cursor_shape_vi_insert: None,
+            cursor_shape_vi_normal: None,

             color_config: HashMap::new(),
             use_grid_icons: true,

Copy link
Collaborator

@fdncred fdncred left a comment

Choose a reason for hiding this comment

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

ok, I'm good with this. Thanks @nibon7!!

@fdncred fdncred merged commit 7907dda into nushell:main Sep 9, 2023
19 checks passed
@mb21
Copy link

mb21 commented Sep 9, 2023

Good idea! And yes, inherit is definitely better wording that none. I was also thinking of dont-change or keep, as that seems technically a bit more correct – if I understand how the cursor shape works in terminal emulators – it seems to be just a global state that any program can alter.


Btw. it could have also been cursor_shape: inherit... but yeah, maybe better keep the config file format synced to the internal Rust sum type, which already can represent nonsensical state like:

edit_mode: emacs,
cursor_shape: {
  vi_insert: line
}

just my two cents ;)

@nibon7 nibon7 deleted the cursor_shape branch September 9, 2023 21:24
@sholderbach sholderbach added the pr:release-note-mention Addition/Improvement to be mentioned in the release notes label Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:release-note-mention Addition/Improvement to be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants