Skip to content

Make cursor_shape optional - #10289

Merged
fdncred merged 3 commits into
nushell:mainfrom
nibon7:cursor_shape
Sep 9, 2023
Merged

fdncred merged 3 commits into
nushell:mainfrom
nibon7:cursor_shape

Conversation

@nibon7

@nibon7 nibon7 commented Sep 9, 2023 •

Copy link
Copy Markdown
Contributor

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

fdncred commented Sep 9, 2023

Copy link
Copy Markdown
Contributor

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

nibon7 commented Sep 9, 2023 •

Copy link
Copy Markdown
Contributor Author

@nibon7

nibon7 commented Sep 9, 2023 •

Copy link
Copy Markdown
Contributor Author

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

fdncred commented Sep 9, 2023 •

Copy link
Copy Markdown
Contributor

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

nibon7 commented Sep 9, 2023

Copy link
Copy Markdown
Contributor Author

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

fdncred commented Sep 9, 2023

Copy link
Copy Markdown
Contributor

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

nibon7 commented Sep 9, 2023 •

Copy link
Copy Markdown
Contributor Author

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,

@fdncred fdncred left a comment

Copy link
Copy Markdown
Contributor

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
@mb21

mb21 commented Sep 9, 2023

Copy link
Copy Markdown

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 notes:mention Noted in "Hall of Fame" section label Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:mention Noted in "Hall of Fame" section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants