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

Autosuggestions do not appear when cursor passes the fish_right_prompt #6948

Closed
tangmi opened this issue Apr 26, 2020 · 3 comments · Fixed by #7035
Closed

Autosuggestions do not appear when cursor passes the fish_right_prompt #6948

tangmi opened this issue Apr 26, 2020 · 3 comments · Fixed by #7035
Labels
bug Something that's not working as intended
Milestone

Comments

@tangmi
Copy link

tangmi commented Apr 26, 2020

$ fish --version
  echo $version
fish, version 3.1.0
3.1.0

$ uname -a
Darwin Mac.local 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64

$ echo $TERM
xterm-256color

Hi, when I have a fish_right_prompt that is very long and type a command that overlaps it, the right prompt disappears (as expected!), but the autosuggestions on the command line stop appearing, as well.

Here is an example of what I'm trying to do:

function fish_prompt
    echo -n "\$ "
end

function fish_right_prompt
    set --local pwd (prompt_pwd)
    set --local prompt_len 2
    set --local rpadding (math -- $COLUMNS - (string length $pwd) - $prompt_len - 2)
    set_color $fish_color_autosuggestion
    echo -n $pwd(string repeat --count $rpadding " ")
    set_color normal
end

At a higher level, I'm trying to create a prompt that shows a "ghost" of $PWD until the user types (please let me know if there's a better way to do this!):

$ _ ~/code/fish-shell
  ^ ^
  | "ghost" of $PWD
  cursor position

$ ls
   ^ ^
   | "ghost" disappears
   user starts to type a command

Many thanks!

@zanchey zanchey added the bug Something that's not working as intended label Apr 26, 2020
@zanchey zanchey added this to the fish-future milestone Apr 26, 2020
@ridiculousfish
Copy link
Member

I think this was originally by design, although I can no longer remember the rationale. If someone would like to tackle this, screen.cpp compute_layout is the place to do it.

@ksralgp
Copy link
Contributor

ksralgp commented May 2, 2020

I have been interested in trying to make a contribution and via some debugging have small idea of how the layout computation works.

I saw this code in screen.cpp:

    // Here are the layouts we try in turn:
    // 1. Left prompt visible, right prompt visible, command line visible, autosuggestion visible.
    //
    // 2. Left prompt visible, right prompt visible, command line visible, autosuggestion truncated
    // (possibly to zero).
    //
    // 3. Left prompt visible, right prompt hidden, command line visible, autosuggestion hidden.
    //
    // 4. Newline separator (left prompt visible, right prompt hidden, command line visible,
    // autosuggestion visible).
    //
    // A remark about layout #4: if we've pushed the command line to a new line, why can't we draw
    // the right prompt? The issue is resizing: if you resize the window smaller, then the right
    // prompt will wrap to the next line. This means that we can't go back to the line that we were
    // on, and things turn to chaos very quickly.

which explains why autosuggestions are not shown because rendering option (3) is happening. @ridiculousfish is the suggestion to add another option that would sit between 2 and 3?

IE Left prompt visible, right prompt hidden, command line visible, autosuggestion visible

On a side-note the comment for (4) suggests autosuggestions should be displayed when the command line extends across multiple-lines. My observation in the code and using fish is currently autosuggesions are omitted. Should I open another issue for that?

@ridiculousfish
Copy link
Member

ridiculousfish commented May 15, 2020

Yeah that's the logic that computes the layout hierarchy. I think #4 is now a stale comment - we no longer push the command to a new line if it grows too long.

@faho faho linked a pull request May 24, 2020 that will close this issue
3 tasks
@faho faho closed this as completed May 24, 2020
faho added a commit that referenced this issue May 24, 2020
@zanchey zanchey modified the milestones: fish-future, fish 3.2.0 May 25, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants