Skip to content

Cursor position after up arrow history cycling is unconventional on multi-line statements #999

Open

Description

@mattmc3

Platform macOS Tahoe
Terminal software WezTerm, but the behavior is the same in other Terminals

Steps to reproduce

  1. Hit the up arrow to cycle to any multi-line statement in history
  2. The cursor is at the end of the first line instead of the end of the multiline command

For example:

ls█  <-cursor after hitting up
::: | where type == file

Expected behavior:

ls
::: | where type == file█  <-cursor after hitting up

Screenshots/Screencaptures

Image

Additional details

I could at least temporarily work around this issue if M-> (meta + greater than) was mapped for emacs mode, or G was mapped for vi mode to take me to the bottom, but neither is so I'm stuck arrowing around my commands.

Activity

  1. fdncred commented on Jan 7, 2026

    @fdncred
    Contributor

    I agree. It seems like the cursor should be to the right of file in your example. I bet this is specific to multiline handling. Thanks. Hopefully someone will be able to locate and fix the issue easily. Seems like it shouldn't be that tricky.

  2. Juhan280 commented on Jan 8, 2026

    @Juhan280
    Contributor

    This isn't actually a bug. Its intended behaviour. When there are multi-line statements in the history, pressing up arrow n times will switch to nth last history. If the cursor was at the end then you would need to press >=n times to get to last nth history item.

    The cursor was put at the end of the line in #899, and then it was reverted in #959.

    I also made a pr to add G motion to vi mode a few months ago, but it didn't get any reviews and was left there: #953

  3. fdncred commented on Jan 8, 2026

    @fdncred
    Contributor

    I still like it at the end better myself. I'm fine with #953 but it doesn't fix the problem in emacs mode.

  4. mattmc3 commented on Jan 8, 2026

    @mattmc3
    Author

    This isn't actually a bug. Its intended behaviour. When there are multi-line statements in the history, pressing up arrow n times will switch to nth last history.

    Oh, I see - the thinking is that that by putting the cursor in an unexpected place at the top of the first line of a buffer you get a shortcut to keep being able to hit up to cycle through history. One of the problems with that method is you then sacrifice the down arrow, which now has to cycle through the whole multiline buffer if you hit up one too many times and now want to go back down the history.

    There are other ways to accomplish this behavior. Using Fish as an example, while you hit up and down it cycles history and the cursor is in the last position, but once you begin editing, then up and down cycle through the lines in the buffer. You can also achieve the same behavior in Zsh with ZLE widgets. See a Zsh example of the behavior I'm after: smart-up-and-down.zsh.

    I'll not try to convince anyone that Nushell's default behavior here is a lousy out-of-the-box experience (which is of course subjective), but being able to fix it with a plugin is an objective measure of how capable reedline is. Is there a way to achieve this through nu scripting, even if it doesn't make it into the codebase as a more reasonable default?

  5. fdncred commented on Jan 8, 2026

    @fdncred
    Contributor

    I think it'll need to be changed in reedline. @ysthakur do you have any thoughts here? I'd also be up for something similar to @Juhan280's reedline PR but for emacs mode like Ctrl-ArrowDown takes you to the end of the multiline command line, or some such hotkey.

  6. ysthakur commented on Jan 9, 2026

    @ysthakur
    Member

    Using Fish as an example, while you hit up and down it cycles history and the cursor is in the last position, but once you begin editing, then up and down cycle through the lines in the buffer.

    This sounds like it'd be best and I'd like to do this eventually, but it probably won't be super easy (not an expert here, can't say for sure).

    @Juhan280's reedline PR but for emacs mode like Ctrl-ArrowDown takes you to the end of the multiline command line, or some such hotkey.

    Yeah, that sounds easiest to implement right now. I'll review #953 soon. Then we can do the same for Emacs.

    Looks like Alt+< and Alt+> correspond to "go to beginning of buffer" and "go to end of buffer," respectively (http://xahlee.info/emacs/emacs/emacs_keys_basics.html).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions