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

Add a way to disable indentation of multi-line commands #1834

Open
1 task done
occivink opened this issue Aug 28, 2024 · 1 comment
Open
1 task done

Add a way to disable indentation of multi-line commands #1834

occivink opened this issue Aug 28, 2024 · 1 comment

Comments

@occivink
Copy link

What new feature should Elvish have?

The editor currently indents multi-line such that they're all aligned with the end of the prompt, like this:

~ my-nice-prompt > some-really-long-com
                   mand --with-long-arg
                   uments --which-cause
                   -wrapping

This is visually pleasing, but makes it inconvenient to copy-paste the command (or parts of it) since a lot of whitespace will be introduced. It would be nice to have an option to enable/disable this behavior, as in my opinion the indentation is not worth the copying troubles.

For info, other shells don't seem to do this kind of indentation.

Output of "elvish -version"

0.20.0-dev.0.20230826021805-1c0cffbfed89

Code of Conduct

@xiaq
Copy link
Member

xiaq commented Oct 21, 2024

Spent a bit of time looking into this while I'm rewriting the TUI.

It's relatively easy to add an API for disabling indentation. But there's a more tricky issue - Elvish also manages line breaks itself instead of using the terminal's own soft line breaks. This means that in the example above:

~ my-nice-prompt > some-really-long-com
                   mand --with-long-arg
                   uments --which-cause
                   -wrapping

The line breaks at the end of each line is actually a hard line break; so even if we get rid of the indentation, you still have those line breaks to deal with.

Preserving soft line breaks is not exactly straightforward, especially in shells with more interactive features. Zsh seems to get this wrong: on my macOS machine using iTerm 2 with zsh 5.9 (arm64-apple-darwin24.0), if I type a long single-line command that spans multiple lines and then copy the command line, I get hard line breaks in between. Bash and Fish do get this correct, to their credits.

It's definitely still possible, but probably not something I'll work on at the moment.

On the other hand, I thought that the following workaround should work:

# Run this in a mini-buffer, or in a keybinding:
edit:notify $edit:current-command

This does get rid of the indentation, but unfortunately it still doesn't get rid of the hard line breaks. I'll push a fix that makes this workaround work soon, though.

xiaq added a commit that referenced this issue Oct 21, 2024
This allows a workaround for #1834.

This change is quite big because it changes the representation of the
notification from a term.Buffer to a ui.Text, which necessitates more downstream
changes.
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

No branches or pull requests

2 participants